1 Attachment(s)

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

Attachment 3542

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?

Re: Binary Search Tree (traversals) Question

Quote:

Originally Posted by

**kraigballa** Does it look like I'm doing this correctly?

Doing what correctly? That tree looks nice though ...

kind regards,

Jos

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?

Re: Binary Search Tree (traversals) Question

Quote:

Originally Posted by

**kraigballa** 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

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.

Re: Binary Search Tree (traversals) Question

Show us your implementation of the different traversals.

kind regards,

Jos

Re: Binary Search Tree (traversals) Question

Quote:

Originally Posted by

**kraigballa** **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

Re: Binary Search Tree (traversals) Question

Yep, that's the idea.

kind regards,

Jos