Question: Consider a set of elements being organized as a binary search tree ( BST ) . The elements in the set may be of different

Consider a set of elements being organized as a binary search tree (BST).
The elements in the set may be of different popularity. That is, a few elements are
searched for much more frequently than others. In order to improve the average
search time, one can consider moving an element in the set that is being searched
for to the top of the BST (so that if the same element is searched for again soon,
the element is likely close to the top of the BST and is thus located with fewer
node checkings). Write an algorithm Search-and-Move(T, k) which searches for and
returns an element with key k in a BST whose root is pointed to by the pointer
T. The algorithm should also restructure the BST so that the element with key k
becomes the root of the tree when the algorithm terminates.

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!