Could someone send me a C coding for converting a generic tree to a binary tree???
Could someone send me a C coding for converting a generic tree to a binary tree???
No, we don't do homework for you. You do it and we help you fix bugs.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
What type of "generic" tree are you needing to convert? How are you nodes connected? Is this a disjointed tree perhaps? Your question is so open ended one can go in any direction with that line of questioning.
I am really new to C programming! My general tree has got one parent, 4 children and 6 grand children.How can i convert this into a binary tree? pls ! tell me the algorithm to do this conversion programming (in "C").I will try to do the programming stuff.
Perhaps think of it MUCH simpler. Build the binary tree from scratch. Traverse the N-ary tree, and build a binary tree as you go.
Or, if you have to do it in-place. Select the correct tree traversal algorithm (you decide which that is), and relink the (hint: bottom) nodes that have already been traversed, building the binary tree as you go.
Neither of which is overly hard to do if you understand trees.
Or, if order and balance doesn't matter (you said binary tree, not binary search tree) then you can simply traverse and relink.
Last edited by zacs7; 11-04-2009 at 05:05 AM.
Thanx for your clarification.