Results 1 to 4 of 4
  1. #1
    scottmulla is offline Member
    Join Date
    Mar 2011
    Posts
    10
    Rep Power
    0

    Question insertion order for complete binary search tree

    what would be the insertion order for the integers 1-26 (inclusive) be in order to come out with a complete binary search tree?

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,655
    Blog Entries
    7
    Rep Power
    21

    Default Re: insertion order for complete binary search tree

    Quote Originally Posted by scottmulla View Post
    what would be the insertion order for the integers 1-26 (inclusive) be in order to come out with a complete binary search tree?
    The left sub tree doesn't just have to be complete, it has to be full, i.e. no more nodes 'fit' in it. A full tree contains 2^n-1 nodes so your left search tree contains 15 nodes. So your right tree contains 10 nodes (the root node is one node too). Your left tree contains the nodes 1 ... 15 so your root node is node 16 and your right sub tree contains the nodes 17 ... 26. Now that you know the value of the root node, apply the above reasoning to the left and right sub trees.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    scottmulla is offline Member
    Join Date
    Mar 2011
    Posts
    10
    Rep Power
    0

    Default Re: insertion order for complete binary search tree

    sssssssssssssssssss
    Last edited by scottmulla; 10-20-2011 at 12:48 PM.

  4. #4
    scottmulla is offline Member
    Join Date
    Mar 2011
    Posts
    10
    Rep Power
    0

    Default Re: insertion order for complete binary search tree

    cheers mate got it sussed

Similar Threads

  1. Replies: 3
    Last Post: 12-06-2010, 04:42 PM
  2. Replies: 0
    Last Post: 04-04-2010, 07:40 AM
  3. Binary search tree search method
    By chopo1980 in forum New To Java
    Replies: 2
    Last Post: 12-10-2009, 01:42 AM
  4. Level order binary tree traversal
    By H3rtaherta in forum New To Java
    Replies: 1
    Last Post: 04-20-2009, 07:34 AM
  5. Binary Search Tree
    By Goo in forum New To Java
    Replies: 0
    Last Post: 03-06-2009, 04:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •