Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. (10 pts.] Consider a general linked-structured binary search tree (BST) implementation for the sorted map ADT. (Note that general BSTs may not satisfy the

image text in transcribedimage text in transcribed

2. (10 pts.] Consider a general linked-structured binary search tree (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.keyk 3: w.value v 4: w.left + left 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 v 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(T, k) 1: if Troot = NULL then return NULL 2: w+ FINDNODE(T.root, k) 3: if w.key = k then return w.value 4: return NULL The function FINDNODE 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 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. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions

Question

Identify these values from Table 11. 7: a. C2 b. R1 c. n d. E2,3

Answered: 1 week ago

Question

1. Signs and symbols of the map Briefly by box ?

Answered: 1 week ago

Question

Types of physical Maps?

Answered: 1 week ago

Question

Explain Intermediate term financing in detail.

Answered: 1 week ago

Question

How We Listen?

Answered: 1 week ago