C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-02-2009, 12:18 AM   #1
Registered User
 
Join Date: Nov 2009
Posts: 3
Question C Code for converting generic to binary code

Could someone send me a C coding for converting a generic tree to a binary tree???
vanilla is offline   Reply With Quote
Old 11-02-2009, 12:26 AM   #2
Algorithm Dissector
 
iMalc's Avatar
 
Join Date: Dec 2005
Location: New Zealand
Posts: 2,476
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
iMalc is offline   Reply With Quote
Old 11-02-2009, 10:45 AM   #3
Registered User
 
slingerland3g's Avatar
 
Join Date: Jan 2008
Location: Seattle
Posts: 476
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.
slingerland3g is offline   Reply With Quote
Old 11-04-2009, 04:44 AM   #4
Registered User
 
Join Date: Nov 2009
Posts: 3
Unhappy Converting generic tree to binary tree

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.
vanilla is offline   Reply With Quote
Old 11-04-2009, 05:02 AM   #5
Woof, woof!
 
zacs7's Avatar
 
Join Date: Mar 2007
Location: Australia
Posts: 3,139
Quote:
Originally Posted by vanilla View Post
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.
__________________
"I.T. gets the chicky-babes" - M. Kelly
bakefile | vim

Last edited by zacs7; 11-04-2009 at 05:05 AM.
zacs7 is offline   Reply With Quote
Old 11-05-2009, 03:34 AM   #6
Registered User
 
Join Date: Nov 2009
Posts: 3
Lightbulb Conversion

Thanx for your clarification.
vanilla is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dec to Binary code 4dice C Programming 7 01-12-2009 03:40 PM
Source code in on machine A, binary is on machine B, is there a way for GDB to refer meili100 C++ Programming 4 01-18-2008 07:05 PM
Trouble reading a binary file as float values - I need the EXPERTs' HELP in C++ code! top_handasa C++ Programming 8 03-26-2007 05:48 PM
Obfuscated Code Contest Stack Overflow Contests Board 51 01-21-2005 04:17 PM
What is binary code? DramaKing A Brief History of Cprogramming.com 11 12-04-2001 11:46 AM


All times are GMT -6. The time now is 03:45 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22