Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a version of a binary search tree (BST) for sorted maps with integer keys that stores additional information as data members of each node

Consider a version of a binary search tree (BST) for sorted maps with integer keys that stores additional information as data members of each node w of the tree to account for the smallest and largest integer keys in the subtree rooted at w. Suppose that we can access this information using w.min, for the smallest integer key, and w.max, for the largest. Algorithm 4 provides the pseudocode for the constructor of a node in a binary tree with the additional information.

image text in transcribed

Note that the data structure must maintain the invariant w.min w.key w.max. Hence, both the insert and delete operations must be properly adapted. Your task is to complete the pseudocode for the insert function, started for you in the partial pseudocode given in Algorithm 6, by writing the missing statements. (NOTE: The missing statements you are asked to write for the insert function in Algorithm 6 only require simple accesses or changes to node ws data members or appropriate reassignment of the variable w itself.)

Igorithm 4 Noek,v,left.rig 1: te new node lte.lalue tr 4: w.left left w.right right w.parent parent 2 min 8: w.maar k return Oue ean adapt the find operation to account for this informatios and potestially stop the search early. Algorithm proviles the peenlocode for the new implementation of the find function. Algorithm 5 find(T.k) 1: te .root 2 while wNULL and w.key do if n or k>mar then return NULL if ku:.key then w.left 6 else te w.right 8: return Algorithm 6 insert T.k, 2 while uNULL and k w.key do 3 if k

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_2

Step: 3

blur-text-image_3

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions