Could someone send me a C coding for converting a generic tree to a binary tree???
Printable View
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.
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.
Thanx for your clarification.