Skip to content

Latest commit

 

History

History
43 lines (22 loc) · 1.65 KB

RedBlackTree.md

File metadata and controls

43 lines (22 loc) · 1.65 KB

RedBlackTree

Implements: IBinarySearchTree<T>

Represents a node-based, self-balancing IBinarySearchTree enhanced to implement an efficient indexer.


Constructors

RedBlackTree() Initializes a new instance of RedBlackTree that is empty.

RedBlackTree(IEnumerable<T> collection) Initializes a new instance of RedBlackTree that contains every item from the input collection.

RedBlackTree(IComparer<T> comparer) Initializes a new instance of RedBlackTree that is empty and uses the specified IComparer.


Properties

int Count Gets the number of elements stored in the RedBlackTree. Complexity: O(1)

T Min Gets the minimum value element stored in the RedBlackTree. Complexity: O(LogN)

T Max Gets the maximum value element stored in the RedBlackTree. Complexity: O(LogN)

T this[int index] Gets the element at the specified index. Complexity: O(LogN)


Methods

int Insert(T value) Inserts an element into the RedBlackTree and returns its index. Complexity: O(LogN)

bool Find(T value) Determines whether the RedBlackTree contains a specific value. Complexity: O(LogN)

bool Remove(T value) Removes one occurrence of a specific element from the RedBlackTree. Complexity: O(LogN)

T[] InOrderTraverse() Returns the list of the elements stored in the RedBlackTree in-order. Complexity: O(N)

T[] PreOrderTraverse() Returns the list of the elements stored in the RedBlackTree pre-order. Complexity: O(N)

T[] PostOrderTraverse() Returns the list of the elements stored in the RedBlackTree post-order. Complexity: O(N)