Thread: Binaray search tree (reverse, postorder)

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    8

    Binaray search tree (reverse, postorder)

    We have the following sequence of numbers : 10, 2, 7, 6, 3, 8, 5, 18, 1 and 9

    a.) Draw binary search tree, which originate, if numbers from sequence are inputed into empty binary search tree and write out sequence of numbers in reverse traversal of a tree
    b.)Draw binary search tree, which originate, if numbers from sequence are inputed into empty binary search tree in reverse order and write out sequence of numbers in preorder traversal.

    Thanks for you help guys

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Are you required to implement a C program here, or is this just a matter of computer science?

    Oh, and what have you tried?
    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
    Mar 2012
    Posts
    8
    I do not need any code i just need to draw binary search tree with this numbers but i do not know how to start

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    *Thread moved to General Discussions*

    Quote Originally Posted by amazineous
    i just need to draw binary search tree with this numbers but i do not know how to start
    Review your notes on binary search trees. In particular, try to construct the examples to get an understanding of what they are about.
    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
    Mar 2012
    Posts
    8
    Are there many possible solutions to this problem ? And how do i know which number is the root. Is it right if i order this numbers into ascending order first and than i construct a binary tree?

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    The way I read the question you should construct the binary search tree that would result from inserting the numbers in sequence into an empty tree. That is, start with an empty tree, then construct the tree you get by inserting the number 10. Then take that tree and construct the tree you get from inserting the number 2 and so on. More info on binary search tree: Binary search tree - Wikipedia, the free encyclopedia

  7. #7
    Registered User
    Join Date
    Mar 2012
    Posts
    8
    So would anyone of you guys who knows how to construct this binary tree be so kind and show me because i got no clue how to start

  8. #8
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Did you read Shakti's post?

    If you use 10 as the root, do you know where 2 will go?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. PostOrder Transversal binary search tree?
    By kevin99 in forum C Programming
    Replies: 4
    Last Post: 06-22-2012, 08:19 AM
  2. Binary Search Tree-search method help?
    By shocklightning in forum C++ Programming
    Replies: 5
    Last Post: 03-25-2012, 10:57 PM
  3. Tree Search
    By Fatima Rizwan in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2010, 09:35 AM
  4. Search Engine - Binary Search Tree
    By Gecko2099 in forum C Programming
    Replies: 9
    Last Post: 04-17-2005, 02:56 PM