Red Black Tree for C++
Requirements:
- Overload the comparison operators, >, <, >=, ==, for the key class.
bool insert(T x, U y): Inserts a key-value pair into the tree. If key already exists, the value would be updated. Input:
- x: key
- y: value Output:
- true if no such key, else false
bool remove(T x): Removes a key-value pair into the tree. Input:
- x: key
- y: value Output:
- true if key is found, else false
bool minimum(T &x, U &y) const: Finds the key-value pair with the smallest key in the tree. Input:
- x: parameter to store the key
- y: parameter to the store the value Output:
- true unless tree is empty
bool maximum(T &x, U &y) const: Finds the key-value pair with the largest key in the tree. Input:
- x: parameter to store the key
- y: parameter to the store the value Output:
- true unless tree is empty
unsigned int getSize() const: Returns the size of the tree. Output:
- size of the tree
bool search(T x, U&y) const: Find the value with the given key. Input:
- x: key to search for
- y: parameter to store the value Output:
- true if key is found, else false
void print(ostream& stream): Prints the whole red-black tree using the provided ostream object