Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Complete the pseudocode for the removeNode method for general BSTs. 2. [14 pts.] In this problem, you will consider pseudocode for algorithms to implement an
Complete the pseudocode for the removeNode method for general BSTs.
2. [14 pts.] In this problem, you will consider pseudocode for algorithms to implement an ordered map ADT (abstract data type) using a general binary search tree (BST) and an AVL tree. You are asked to complete missing stateentso the pseudocode for the impleen tation eith by witing down the missing statement or by matching a given statement to the corresponding index of the missing statement in the pseudocode. You are also asked to provide asymptotic growth rate for the worst-case rung time and space coplexity of some of the algorithms (a) 6 pts.] BST Operations: Pseudocode and Asymptotic Analysis Algorith 1 provides the pseudocode for the constructor of a node to be used in an AVI tree, often denoted here by T, so that T.oois either a node, or NULL if T is empty You can assue that the function height() returns the corsponding height of node w in the tree, which is 0 f NULL, and w.height otherwise Algorithm 1 Node(k, w, left, right,parent) 1: TL, new node 2: w.key k 3: w.valuev 1: w.leftleft 5: u,right right 6: w.parent f parent 7: w.height1max(height (le ft), height(right)) 8: return w Algorithm 2 is the corresponding implementation of the find etod of a ordered map ADT, which works on any BST. It has been mdified slightly here to facilitate the implementation of the putAVL and eraseAVL ethods, the corresponding versions of the put ad erase operatons for arbitrary BSTs, considered later in this probl In particular, find takes as iput a BST T and a key k, and outputs a pair of nodes (w,z), where w is the node with the key k if found in T, and z the parent node of w; if key k is not in T, thenis NULL and z is the last node traversed while searching for key k (Note that w can be NULL ad zcan also be NULL in general.) Algorithm 2 find(T,k) 2: while u,NULL and k:w.key do 3: w.parent 1: if kStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started