c# - Recursive Tree Mapping -


I've been working a lot with tree implementation lately and we represent and understand the trees. My focus has been focused on converting mathematical expressions into binary trees, I have called the problem of representing a tree in a linear form as a string or an array, while still important information about trees and its sub-trees

Like I have actually developed a simple encoding for the binary expression tree though I have a There are some problems with implementing it effectively in Ravarati Manor, it seems to be a failed aspect behind this concept.

The encoding is simple if the node remains in the form of a left child. Map of 1 if it remains in the right child, then it is given 0. This simple encoding allows me to encode whole balanced and unbalanced trees in this way:

  ## ## / \ / / 1 0 or 0 / / / / 10 10 01 00 01 00   

for depth trees etc

Does anyone have any suggestions as to how to create a recursive function which is this kind of mapping (example For ## 1 11 10 0 01 00) representing the prefix string.

I was told that it would be difficult / impossible due to keeping track of time between 1 and 0 during the maintenance and insertion of parents.

I wonder how anyone has any insight or idea in doing this with C # ??

I'm not sure that I understand the problem but there is something here that can help one Solution An graph can be implemented on the graph traversal routine (a tree remembers a special graph), where you get node / vertex for the first time. I apologize for posting Java code when you are asked for C # but I know that Java ...

  public zero depth first search (graph graph, vertex starting) ) {Set   

You can easily modify it Search the width first by using the deck instead of the stack as a queue:

  stack.pop ()> gt; & Gt; & Gt; & Gt; Queue.removeFirst () stack.push () & gt; & Gt; & Gt; & Gt;   

Note that for this purpose, the Articles and Edge Class support the following tasks:

  Public interface graphs ... ... / Vertex V Get the starting edges from the local listing & lt; Edge & gt; GetEdges (Vertix V); ...} Public interface edge {... // Get on top at the beginning of the edge / has not been used here, but like contained by getEndVertex () ... Public Vertex GetStartVertex (); // Get the peak at the end of the edge Vertex getEndVertex (); ...}   

Hope this gives you some ideas.

Comments