

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


30 50 70 10 40 80 20 60
1. Consider the binary search tree shown above. a. What tree results after you insert the nodes 65 , 75 , 43 , 47 , 35 , and 25 in that order. Note: not an AVL tree; a Binary Search Tree. 30 50 70 10 40 80 20 60 65 75 43 47 25 35
b. After inserting the nodes mention in Part a , what tree results when you delete node 40 using the following strategies? i. Show the Part a tree after the deletion if the in-order predecessor is used as the replacement for the deleted node. 30 50 70 10 35 80 20 60 65 75 43 47 25 ii. Show the Part a tree after the deletion if the in-order successor is used as the replacement for the deleted node. 30 50 70 10 43 80 20 60 65 75 25 35 47
2. Suppose that you traverse the binary search tree as it is given above (i.e., before the changes) and write the data item in each node visited to a file. You plan to read this file later and create a new binary search tree using the binary search tree operation insert. In creating the file, in what order (of the ones that we covered) should you traverse the tree so that the new tree will have exactly the same shape and nodes as the original tree? What does the file look like after the original tree is traversed. [Hint: ask yourself where the root must occur in this data file.] You can either use a pre-order traversal or a level-order traversal. Pre-order file: 40 20 10 30 60 50 80 70 Level-order file: 40 20 60 10 30 50 80 70