Results 1 to 8 of 8
  1. #1
    kraigballa is offline Senior Member
    Join Date
    Oct 2011
    Posts
    115
    Rep Power
    0

    Default Binary Search Tree (traversals) Question

    Here is the question:

    1.)Draw the tree that would be formed by inserting the words in this question into a binary search tree. Use lowercase letters.

    Here's what I have:

    Binary search tree with 22 words will have only 20 words as the and tree are repeated...I believe this is correct
    Binary Search Tree (traversals) Question-tree.jpg


    2.) Show all three traversals of this tree.

    Inorder:
    a binary by be draw formed in letters lowercase into question search inserting that the this tree use words would
    Preorder:
    draw be a by binary the that formed inserting in question into lowercase letters search tree this would words use
    Postorder:
    a binary by be formed in letters lowercase into search question inserting that this use words would tree the draw

    or

    draw the tree would words use this that formed inserting question search into lowercase letters be by binary a


    Does it look like I'm doing this correctly?

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

    Default Re: Binary Search Tree (traversals) Question

    Quote Originally Posted by kraigballa View Post
    Does it look like I'm doing this correctly?
    Doing what correctly? That tree looks nice though ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    kraigballa is offline Senior Member
    Join Date
    Oct 2011
    Posts
    115
    Rep Power
    0

    Default Re: Binary Search Tree (traversals) Question

    Doing the problems...does the tree look correct. And then for part 2, do my traversals of that tree look correct?

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

    Default Re: Binary Search Tree (traversals) Question

    Quote Originally Posted by kraigballa View Post
    Doing the problems...does the tree look correct. And then for part 2, do my traversals of that tree look correct?
    The tree looks fine to me but I don't understand your remarks/comment for the three traversals of a binary tree ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    kraigballa is offline Senior Member
    Join Date
    Oct 2011
    Posts
    115
    Rep Power
    0

    Default Re: Binary Search Tree (traversals) Question

    For part 2 you have to take the words off the tree in a certain order based on what traversal it is. I Google'd each and after readin what they were supposed to do I implemented it on my tree. However, I'm not sure if they are correct.

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

    Default Re: Binary Search Tree (traversals) Question

    Show us your implementation of the different traversals.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    kraigballa is offline Senior Member
    Join Date
    Oct 2011
    Posts
    115
    Rep Power
    0

    Default Re: Binary Search Tree (traversals) Question

    Quote Originally Posted by kraigballa View Post
    Inorder:
    a binary by be draw formed in letters lowercase into question search inserting that the this tree use words would
    Preorder:
    draw be a by binary the that formed inserting in question into lowercase letters search tree this would words use
    Postorder:
    a binary by be formed in letters lowercase into search question inserting that this use words would tree the draw

    or

    draw the tree would words use this that formed inserting question search into lowercase letters be by binary a
    Did this by reading this:
    Preorder traversal
    node, left, right
    prefix expression

    Postorder traversal
    left, right, node
    postfix expression

    Inorder traversal
    left, node, right
    infix expression

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

    Default Re: Binary Search Tree (traversals) Question

    Yep, that's the idea.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Binary search tree
    By hansmoolman in forum New To Java
    Replies: 2
    Last Post: 10-28-2010, 01:59 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. Binary Tree Traversals and Swapping
    By Sylar in forum New To Java
    Replies: 0
    Last Post: 03-08-2009, 07:52 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
  •