I'm looking for an implementation of a Red-Black Tree in C#, with the following features:
T
by different fields in it.T
, but it'll accept the field type sorting it.Thank you.
A Red Black Tree is a category of the self-balancing binary search tree. It was created in 1972 by Rudolf Bayer who termed them "symmetric binary B-trees." A red-black tree is a Binary tree where a particular node has color as an extra attribute, either red or black.
Red-black trees are a fairly simple and very efficient data structure for maintaining a balanced binary tree. The idea is to strengthen the representation invariant so a tree has height logarithmic in n. To help enforce the invariant, we color each node of the tree either red or black.
4.3. Functional Programming. RB trees are used in functional programming to construct associative arrays. In this application, RB trees work in conjunction with 2-4 trees, a self-balancing data structure where every node with children has either two, three, or four child nodes.
You mostly just described SortedDictionary<T, U>
, except for the next-lowest/next-highest value binary search, which you could implement on your own without much difficulty.
Are there specific reasons that SortedDictionary
is insufficient for you?
Rip the TreeSet from C5 collection libs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With