Red-black tree is known for an efficient data structure use in computer science. It is a type of self-balance binary search tree, it performs insertion, deletion, searching,.. in the worst running time of O(lg n). This is my red-black tree implementation in C++:
RB-Tree implementation
It provides the following function:
- iterator object: An object that contains:
+ T1 key: return the key of the object of type T1.
+ T2 value: return the value of the object of type T2.
+ bool hasKey: Indicates if this is a null object or not.
+ iterator(): default constructor.
+ iterator(T1 myKey, T2 myValue): constructor.
- Insert(T1 key, T2 value): Insert a new item with specific key and value, all items must have different key.
- Erase(iterator &iter): Delete an iterator object.
- Search(T1 key): Search for a key in the tree, return an iterator value, the iterator value will have hasKey = true if the search successed of false if it didnt.
No comments:
Post a Comment