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

MC7 (2.5pts) Examine the mysteryFunction below? (Note that in context, t->right

ID: 3724354 • Letter: M

Question

MC7 (2.5pts) Examine the mysteryFunction below? (Note that in context, t->right will not be NULL.) void mysteryFunction(treeNode * & t) 1 treeNode * y = t->right; t->right = y->left; y->left = t; y->height = max( height (y->right), t->height = max ( height (t->right), t=y; height (y->left)) height(t->left)) 1; 1; + + Which of the following Dictionary functions could invoke mysteryFunction more than once? (a) insert (key); (b) remove (key); (c) find(key) (d) Two or more of these could invoke mysteryFunction more than once (e) None of these would invoke mysteryFunction more than once.

Explanation / Answer

During Removal, Tree might become unbalanced, So we need to peform Rotation and update the height and call mystery function

find will never invoke it

Insertion can invoke if if the tree is unbalanced and we need to update the height

Hence the answer is (d) : Two or more of these could invoke Mystery function