Question: 3. (16 pts.] Consider the SUCCESSOR function (Algorithm 4) for a general linked-structured BST implementation for a sorted map ADT. It takes as input a

3. (16 pts.] Consider the SUCCESSOR function (Algorithm 4) for a general linked-structured BST implementation for a sorted map ADT. It takes as input a node w in a general BST and outputs its successor node in the BST, that is, the node whose key immediately follows the key w.key of node w, if any otherwise it outputs NULL. It uses two auxiliary functions, FIRSTLEFT ANCESTOR and FLOOR ENTRYNODE. Algorithm 4 SUCCESSOR (W) 1: if w = NULL then return w 2: if w.right = NULL then return FIRSTLEFTANCESTOR(0) 3: return FLOORENTRYNODE(w.right) (b) Write an algorithm, using pseudocode, for the function FLOOR ENTRYNODE, which takes as input a node w in the BST and outputs the node with the smallest key in the subtree rooted at w, that is, the last left ancestor of w or said differently, the left-most node in the subtree rooted at w); it outputs NULL if no such node exists, or if the subtree is empty. The algorithm should run in time that is linear in the height of the subtree rooted at w, and use a constant amount of space
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
