Thread: C Code for converting generic to binary code

  1. #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???

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    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"

  3. #3
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    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.

  4. #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.

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    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.
    Last edited by zacs7; 11-04-2009 at 05:05 AM.

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    3

    Lightbulb Conversion

    Thanx for your clarification.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dec to Binary code
    By 4dice in forum C Programming
    Replies: 7
    Last Post: 01-12-2009, 03:40 PM
  2. Replies: 4
    Last Post: 01-18-2008, 07:05 PM
  3. Replies: 8
    Last Post: 03-26-2007, 05:48 PM
  4. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  5. What is binary code?
    By DramaKing in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 12-04-2001, 11:46 AM