Question: Rank query. Add to BST a method rank() that takes a key as an argument and returns the number of keys in the BST that
Rank query. Add to BST a method rank() that takes a key as an argument and returns the number of keys in the BST that are strictly smaller than key. Maintain subtree sizes in each node (see EXERCISE 4.4.29). The running time should be proportional to the height of the tree.
Data from in Exercise 4.4.29
Modify BST to add a method size() that returns the number of key-value pairs in the symbol table. Use the approach of storing within each Node the number of nodes in the subtree rooted there.
Step by Step Solution
3.38 Rating (157 Votes )
There are 3 Steps involved in it
To solve this problem we need to manipulate the properties certain properties of a Binary Search Tree BST In a standard BST any nodes left subtree con... View full answer
Get step-by-step solutions from verified subject matter experts
