Red-Black tree Restructuring - red-black-tree

I really wonder that is there any change of Black node number from External node to Root node when restructuring processor is occur.
plz answer me.
( I really sorry about my English poor. )

Related

Modify Parse Tree

I have an ANTLR ParseTree for an sql grammar.
Example :
My goal is to edit this tree so that i can delete all the middle (booleanExpression, predicated, valueExpression, primaryExpression ) nodes inbetween.
I have explored visitor and listenors but they don’t generate the tree for me. And i'd like to not touch the grammar since its the official source one.
So how can i do it?
Thanks
There is no such feature in ANTLR's API (removing/mutating the ParseTree). You'll have to walk the tree yourself and create a copy of the ParseTree and ignore certain sub-trees you do not want/need.
I’ve usually found the ParseTree to be too cumbersome (for exactly the reason you’ve shown). I don’t know of any automated way to alter the tree in memory. ( Could be an interesting project to attempt.)
I a couple of implementations I’ve written some generalized approach to make the process easier. The “best” one was where I wrote a small DSL to define the structure I wanted. It generated the classes as well as ANTLR style visitors and listeners for those. I then used a listener to transform the ANTLR ParseTree to my ideal tree, and wrote the rest of my code using that structure with that, much simpler, tree. You can have a listener/visitor generate a tree of your own design as an artifact of processing the ParseTree, but that’s as close as I’ve come.
It was actually a relatively minor effort to set that up early in the process and accounted for a quite small percentage of the overall effort of implementing the language (so, well worth the effort).

Executing a Genetic Programming tree

I am running GP algorithm using ECJ 26 during that I use describe() function to test the tree, however, currently I need to store and execute the tree outside ECJ framework.
Please, could you let me know if it is possible?
Thanks in advance.
The simplest approach to executing a tree (like an abstract syntax tree) would be traversing the tree using the visitor pattern and taking actions based on the current node and the current state of the executor (your "virtual machine"). This is how the so called tree walk interpreters work (a typical example is the Ruby interpreter prior to v1.9).
This is for sure a very generic answer, but hopefully it'll give you some ideas.

Guide in solving spoj GiveAway

I was unable to solve the problem Spoj Give away after thinking for a while and searching for help I came to know that it involves AVL Tree + Segement Tree . Since I haven't used this data Structure yet a detail explanation of Working code and the approach is much encouraged.
Link : http://www.spoj.com/problems/GIVEAWAY/
In SPOJ GIVEAWAY, the problem requires you to address a lot of queries and whenever we have to handle more than one queries, SQRT decomposition technique or Segment tree comes forward. I would suggest you to solve the problem using SQRT decomposition method. If you're new to both the methods, you can watch tutorials or some documentation on the internet. I'm providing some links I hope it'll help you ;)
SQRT Decomposition
Segment Tree

SSADM for Dummies

this question might look dumb but I need to have a clear idea when learning about something new :)
In SSADM, do we have to do a comprehensive study about the "feasibility" (Stage0)? How can we get an idea about the feasibility before even performing "investigation" (Stage1) about the business?
What is actually expected in Stage0 anyway?
Thanks. Hope someone would shed a light on this.
My references are not available to me at the moment so this is from memory - I think the feasibility stage is about getting the project off the ground - why should people commit resources to even an investigation. So when they are talking about feasibility, and the contents of the report things that are likely to be covered are a broad statement of the problem; why it is a problem; why a system solution looks like the way to go to solve the problem; who will pay for it; who is sponsering it and who will benefit from it.
By definition, it is impossible to do a comprehensive study of feasibility before getting into the work, but rather I think of a feasibility picture as painting a picture of what might be if this project were to go ahead - so broad stroke rather than detailed and comprehensive.
In essence the feasibility stage is answering the questions "why should we bother with this project; and if we are bothered to do this project do we think we are capable of doing it.

Hierarchical state machine implementation in Erlang

I am planning a turn based game (a sort of board game), and the backend will probably be done in Erlang. The game logic part seems to be a fit for a hierarchical state machine, but I'm not sure about how to implement that in Erlang.
Maybe I can spawn a separate process with each child fsm, not sure if this would work.
Another option would be to embed a scripting language or create a DSL for this purpose.
What do you think?
Thanks.
I am the original question author (in fact I would like to claim the question as mine, but I don't know how).
I already know about all the things OTP offers, gen_fsm included.
The idea is to use a HIERARCHICAL state machine, and gen_fsm is a plain state machine. To keep track of the game turns, phases, etc, I don't think a plain state machine as gen_fsm would be enough.
Anyway, I have been investigating further, and I think that I will use erl-lua so I can use Lua for all the game logic. Once it is working I can search for bottlenecks and move them to a C implementation or whatever.
#codecaster you can use gen_fsm to track the state and just build in an additional level of state inside the fsm state... however, erl-lua would work as well. I built a monitoring tool with it called erlmon - we had some trouble with erl-lua crashing so keep in mind it's not bug free. also with the new support for Nifs, i'm waiting for someone to write a new driver for lua that is nif-based - you might want to look around for that - i haven't seen anyone build one yet.
As a starting point, I would suggest you to have a look to the OTP design principles. You'll probably want to have a more detailed look at supervisors and generic FSMs.