Consider the following algorithm that inserts a new element in the root, not in a leaf (Stephenson 1980):
rootInsertion(el) p = root; q1 = 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->elel if q1 == root q1->left = p; else q1->right = p; q1 = p; p = p->right;q1->left = q2->right = 0;
Show the trees when the following numbers are inserted:
a. 5 28 17 10 14 20 15 12 5
b. 1 2 3 4 5 6 7
When do root insertion and leaf insertion render the same tree?
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.