Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) a) Draw all possible binary search trees for the three elements A, B, and C.

ID: 3543612 • Letter: 1

Question

1) a) Draw all possible binary search trees for the three elements A, B, and C.

b) What are the minimum and maximum numbers of leaves in a balanced tree of height h?

2) a) Using inorder, preorder, and postorder tree traversal, visit only leaves of a tree. What can you observe? How can you explain this phenomenon?

b)

need detailed explanation...

Consider the following algorithm that inserts a new element in the root, not in a leaf (Stephenson 1980): rootInsertion(el) p = root ; ql = q2 = root = new BSTNode(el); while p 0 if p->el root->el if q2 == root q2->right = p; else q2->left = p; q2 = p; p = p->left; else // if p->el el if ql == root ql->left = p; else ql->right = p; ql = p; p = p->right; ql->left = q2->right = 0; Show the trees when the following numbers are inserted: 5 28 17 10 14 20 15 12 5 1234567 When do root insertion and leaf insertion render the same tree?

Explanation / Answer