Skip to content

Caixin89/RBTree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RBTree

Red Black Tree for C++

Requirements:

  1. 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:

  1. x: key
  2. y: value Output:
  3. true if no such key, else false

bool remove(T x): Removes a key-value pair into the tree. Input:

  1. x: key
  2. y: value Output:
  3. 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:

  1. x: parameter to store the key
  2. y: parameter to the store the value Output:
  3. 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:

  1. x: parameter to store the key
  2. y: parameter to the store the value Output:
  3. true unless tree is empty

unsigned int getSize() const: Returns the size of the tree. Output:

  1. size of the tree

bool search(T x, U&y) const: Find the value with the given key. Input:

  1. x: key to search for
  2. y: parameter to store the value Output:
  3. true if key is found, else false

void print(ostream& stream): Prints the whole red-black tree using the provided ostream object

About

Red Black Tree for C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages