{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CSE331_HW4 - 1 a 3 1 4 2 6 5 9 7 b 4 1 6 2 5 7 9 2 a C X G...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1. a. 3 1 4 2 6 5 9 7 b. 4 1 6 2 5 9 7 2. a. C X G B Y P A
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
b. This is the only way to make such a binary tree because the entire tree can only be drawn this way to represent both in-order and pre-order. For example for the right edge you can do it differently for just in-order but because it has to be the same as pre-order you have to put the node p on the right child of node g. Since in-order is starting from the left it ensures node P is last. c. The method I used was going node by node and fitting them in. I knew C would have to be the root node because it was the first in pre-order. Next I knew the farthest left node was going to have to be node B to satisfy in-order. I made X the parent node of B to also satisfy in-order and knew that my left most edge was complete because it satisfied both in and pre-order. Next I knew I had to place A and Y in the left side of the tree because C was my root node. The next part was easy because with pre-order there are more ways to
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}