Thread: binary tree

  1. #1
    Registered User
    Join Date
    Oct 2011
    Location
    india
    Posts
    18

    binary tree

    can anyone post the function to insert elements into a binary tree?[not binary search tree]

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by vikasvijayan
    can anyone post the function to insert elements into a binary tree?[not binary search tree]
    It depends on what is the binary tree and how it was implemented.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2011
    Location
    india
    Posts
    18
    can you give the general inserting procedure by using linkedlist?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by vikasvijayan
    can you give the general inserting procedure by using linkedlist?
    There is no "general inserting procedure". For example, can you give the general inserting procedure for eating food? If you started with "pick up your fork and spoon", you're wrong, because I intend to use chopsticks for lunch. If you skip that part, you're wrong, because the tools are essential (even if only hands are used). Clearly, I should elaborate, e.g., on the kind of food, the environment, etc.

    So, why don't you show your binary tree implementation thus far?

    By the way, what's with the "not binary search tree" clause?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Oct 2011
    Location
    india
    Posts
    18
    i know the procedure for binary search tree...

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by vikasvijayan
    i know the procedure for binary search tree...
    I see. So what problem are you facing now? If you can insert into a binary search tree that is implemented using pointers as in a linked list, you should be able to insert into a binary tree that is implemented using pointers as in a linked list.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting From Binary Tree to Threaded Binary Trees
    By elton_fan in forum C Programming
    Replies: 15
    Last Post: 11-08-2007, 11:41 PM
  2. Replies: 2
    Last Post: 08-01-2007, 01:08 PM
  3. Replies: 0
    Last Post: 11-04-2006, 11:07 AM
  4. display tree data in binary tree format
    By xddxogm3 in forum C++ Programming
    Replies: 4
    Last Post: 12-11-2003, 12:47 AM
  5. b-tree (not binary tree) implementation help
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 01-02-2002, 03:30 PM