Question: A binary search tree is implemented using the following node and class structure. Write a method void rank( int k , Entry &x) that returns
A binary search tree is implemented using the following node and class structure. Write a method void rank(int k, Entry &x) that returns the k-th ranked entry in x (assume 1<=k<=n where n is the number of items in the binary search tree.) Your method should stop the search as soon as the k-th item is found.
template <class Entry>
struct Binary_node {
// data members:
Entry data;
Binary_node
Binary_node
// constructors:
Binary_node( );
Binary_node(const Entry &x);
};
template <class Entry>
class Binary_tree {
public:
Binary_tree( );
bool rank(int k, Entry &x); // returns the k-th ranked entry in x
protected:
// Add auxiliary function prototypes here.
Binary_node
};
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
