Question: Complete the pseudocode for the algorul IINDNOD Algorithm 3) hy marching anchising statements number listed ca the left hand side below, with a corresponding operation,

 Complete the pseudocode for the algorul IINDNOD Algorithm 3) hy marchinganchising statements number listed ca the left hand side below, with acorresponding operation, listed on the right-hand side below. Note that the same

Complete the pseudocode for the algorul IINDNOD Algorithm 3) hy marching anchising statements number listed ca the left hand side below, with a corresponding operation, listed on the right-hand side below. Note that the same operation on the right way watch wipie statements on the lef) 2. 110 pts. Consider a general linked-structured imary sealt tree (AST) implementation for the sorted map ADT. (Note that general BSTs may not satisfy the height balance property.) Algorithm 1 provides the pseudocode for the constructor of a node in a BST. Algorithm 3 FINDNODE.) left, righi, prirent) 2. while wf-NULL do 2: if w key = k then relurn w Algorithm 1 NoDaik, 1: We new node 2 w.keyk >w.value 4. w.left left S: W.right right 6: W.parent parent 7 return w if w.key > & then else Statement # Operation Algorithm 2 provides the pseudocode for an implementation of the FIND function. It takes is input a BST T with root node 7.root and a key k, and outputs the value associated with key & in the sorted map, or NULL it the map does not contain that key. It uses the function IINDNODE (Algorithm 3 on next page, still incomplete) as an auxiliary method. Statement W w .lelt Statement 4 return Algorithm 2 FINDI,k) 1. ir 7 root = NULL, then return NULL 2: W - FINDNODE(T.100tk) 3.1f w.key-k then return w.value 4: return NULL Salement 6 W w .right The function FINDNODE takes as input a non-NULL rode w in the tree and a key k, and outputs the last node visited during the search: that is either (1) & node win the tree with the key k or (2) the last node considered during the search if no node with key k was found. It assumes that it is the responsibility of the calling function to determine whether the search was successful or not by checking whether the output node contains the key k or not. Statement uchi no node with i lity of the calling vessful er not by She Statement 9 Write down tight high characterizations of the worst-case running time and space complex- ity of the implementation of the 'IND method (Algorithm 2) as a function of the number of nodes n in the general BST. ime Space 2. [10 pts. Consider a general linked-structured binary search tres (BST) implementation for the sorted map ADT. (Note that general BSTs may not satisfy the height-balance property.) Algorithm 1 provides the pseudocode for the constructor of a node in a BST. Algorithm 1 NODE(K,v,left, right parent) 1. W new node 2 w key * 3: w.value 4. w.left len 5:w.right right 6:w.parent-parent 7: return w Algorithm 2 provides the pseudocode for an implementation of the FIND function. It takes as input a BST T with root node T.root and a key k, and outputs the value y associated with key k in the sorted map, or NULL if the map does not contain that key. It uses the function FINDNODE (Algorithm 3 on next page, still incomplete) as an auxiliary method. Algorithm 2 FIND(Tk) 1: if T.root - NULL then return NULL 2: W FINDNODE(T root k) 3: if w. key = i then return w.value 4: return NULL The function FIND NODE takes as input a non-NULL node w in the tree and a key k. and outputs the last node visited during the search: that is, either (1) a node w in the tree with the key k or (2) the last node considered during the search if no node with key was found. It assumes that it is the responsibility of the calling function to determine whether the search was successful or not by checking whether the output node contains the key k or not. Complete the pseudocode for the algorithm FIND NODE (Algorithm 3) by matching each missing statements number-listed on the left hand side below, with a corresponding operation, listed on the right-hand side below. (Note that the same operation on the right may match multiple statements on the left) Algorithm 3 FINDNODE(w.k) 2: while w f= NULL do if w.key-k then return w if w.key> kthen else Statement # Operation Statement i 1 w .left Statement 4 return Statement 6 W w .right Statement 8 Statement 9 Write down tight big-Oh characterizations of the worst-case running time and space complex-ity of the implementation of the FIND method (Algorithm 2) as a function of the number of nodes n in the (general) BST. Time Space 2. [10 pts. Consider a general linked-structured binary search tres (BST) implementation for the sorted map ADT. (Note that general BSTs may not satisfy the height-balance property.) Algorithm 1 provides the pseudocode for the constructor of a node in a BST. Algorithm 1 NODE(K,v,left, right parent) 1. W new node 2 w key * 3: w.value 4. w.left len 5:w.right right 6:w.parent-parent 7: return w Algorithm 2 provides the pseudocode for an implementation of the FIND function. It takes as input a BST T with root node T.root and a key k, and outputs the value y associated with key k in the sorted map, or NULL if the map does not contain that key. It uses the function FINDNODE (Algorithm 3 on next page, still incomplete) as an auxiliary method. Algorithm 2 FIND(Tk) 1: if T.root - NULL then return NULL 2: W FINDNODE(T root k) 3: if w. key = i then return w.value 4: return NULL The function FIND NODE takes as input a non-NULL node w in the tree and a key k. and outputs the last node visited during the search: that is, either (1) a node w in the tree with the key k or (2) the last node considered during the search if no node with key was found. It assumes that it is the responsibility of the calling function to determine whether the search was successful or not by checking whether the output node contains the key k or not. Complete the pseudocode for the algorithm FIND NODE (Algorithm 3) by matching each missing statements number-listed on the left hand side below, with a corresponding operation, listed on the right-hand side below. (Note that the same operation on the right may match multiple statements on the left) Algorithm 3 FINDNODE(w.k) 2: while w f= NULL do if w.key-k then return w if w.key> kthen else Statement # Operation Statement i 1 w .left Statement 4 return Statement 6 W w .right Statement 8 Statement 9 Write down tight big-Oh characterizations of the worst-case running time and space complex-ity of the implementation of the FIND method (Algorithm 2) as a function of the number of nodes n in the (general) BST. Time Space Complete the pseudocode for the algorul IINDNOD Algorithm 3) hy marching anchising statements number listed ca the left hand side below, with a corresponding operation, listed on the right-hand side below. Note that the same operation on the right way watch wipie statements on the lef) 2. 110 pts. Consider a general linked-structured imary sealt tree (AST) implementation for the sorted map ADT. (Note that general BSTs may not satisfy the height balance property.) Algorithm 1 provides the pseudocode for the constructor of a node in a BST. Algorithm 3 FINDNODE.) left, righi, prirent) 2. while wf-NULL do 2: if w key = k then relurn w Algorithm 1 NoDaik, 1: We new node 2 w.keyk >w.value 4. w.left left S: W.right right 6: W.parent parent 7 return w if w.key > & then else Statement # Operation Algorithm 2 provides the pseudocode for an implementation of the FIND function. It takes is input a BST T with root node 7.root and a key k, and outputs the value associated with key & in the sorted map, or NULL it the map does not contain that key. It uses the function IINDNODE (Algorithm 3 on next page, still incomplete) as an auxiliary method. Statement W w .lelt Statement 4 return Algorithm 2 FINDI,k) 1. ir 7 root = NULL, then return NULL 2: W - FINDNODE(T.100tk) 3.1f w.key-k then return w.value 4: return NULL Salement 6 W w .right The function FINDNODE takes as input a non-NULL rode w in the tree and a key k, and outputs the last node visited during the search: that is either (1) & node win the tree with the key k or (2) the last node considered during the search if no node with key k was found. It assumes that it is the responsibility of the calling function to determine whether the search was successful or not by checking whether the output node contains the key k or not. Statement uchi no node with i lity of the calling vessful er not by She Statement 9 Write down tight high characterizations of the worst-case running time and space complex- ity of the implementation of the 'IND method (Algorithm 2) as a function of the number of nodes n in the general BST. ime Space 2. [10 pts. Consider a general linked-structured binary search tres (BST) implementation for the sorted map ADT. (Note that general BSTs may not satisfy the height-balance property.) Algorithm 1 provides the pseudocode for the constructor of a node in a BST. Algorithm 1 NODE(K,v,left, right parent) 1. W new node 2 w key * 3: w.value 4. w.left len 5:w.right right 6:w.parent-parent 7: return w Algorithm 2 provides the pseudocode for an implementation of the FIND function. It takes as input a BST T with root node T.root and a key k, and outputs the value y associated with key k in the sorted map, or NULL if the map does not contain that key. It uses the function FINDNODE (Algorithm 3 on next page, still incomplete) as an auxiliary method. Algorithm 2 FIND(Tk) 1: if T.root - NULL then return NULL 2: W FINDNODE(T root k) 3: if w. key = i then return w.value 4: return NULL The function FIND NODE takes as input a non-NULL node w in the tree and a key k. and outputs the last node visited during the search: that is, either (1) a node w in the tree with the key k or (2) the last node considered during the search if no node with key was found. It assumes that it is the responsibility of the calling function to determine whether the search was successful or not by checking whether the output node contains the key k or not. Complete the pseudocode for the algorithm FIND NODE (Algorithm 3) by matching each missing statements number-listed on the left hand side below, with a corresponding operation, listed on the right-hand side below. (Note that the same operation on the right may match multiple statements on the left) Algorithm 3 FINDNODE(w.k) 2: while w f= NULL do if w.key-k then return w if w.key> kthen else Statement # Operation Statement i 1 w .left Statement 4 return Statement 6 W w .right Statement 8 Statement 9 Write down tight big-Oh characterizations of the worst-case running time and space complex-ity of the implementation of the FIND method (Algorithm 2) as a function of the number of nodes n in the (general) BST. Time Space 2. [10 pts. Consider a general linked-structured binary search tres (BST) implementation for the sorted map ADT. (Note that general BSTs may not satisfy the height-balance property.) Algorithm 1 provides the pseudocode for the constructor of a node in a BST. Algorithm 1 NODE(K,v,left, right parent) 1. W new node 2 w key * 3: w.value 4. w.left len 5:w.right right 6:w.parent-parent 7: return w Algorithm 2 provides the pseudocode for an implementation of the FIND function. It takes as input a BST T with root node T.root and a key k, and outputs the value y associated with key k in the sorted map, or NULL if the map does not contain that key. It uses the function FINDNODE (Algorithm 3 on next page, still incomplete) as an auxiliary method. Algorithm 2 FIND(Tk) 1: if T.root - NULL then return NULL 2: W FINDNODE(T root k) 3: if w. key = i then return w.value 4: return NULL The function FIND NODE takes as input a non-NULL node w in the tree and a key k. and outputs the last node visited during the search: that is, either (1) a node w in the tree with the key k or (2) the last node considered during the search if no node with key was found. It assumes that it is the responsibility of the calling function to determine whether the search was successful or not by checking whether the output node contains the key k or not. Complete the pseudocode for the algorithm FIND NODE (Algorithm 3) by matching each missing statements number-listed on the left hand side below, with a corresponding operation, listed on the right-hand side below. (Note that the same operation on the right may match multiple statements on the left) Algorithm 3 FINDNODE(w.k) 2: while w f= NULL do if w.key-k then return w if w.key> kthen else Statement # Operation Statement i 1 w .left Statement 4 return Statement 6 W w .right Statement 8 Statement 9 Write down tight big-Oh characterizations of the worst-case running time and space complex-ity of the implementation of the FIND method (Algorithm 2) as a function of the number of nodes n in the (general) BST. Time Space

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!