Is SortedDictionary a red-black tree?

Nahum picture Nahum · Feb 16, 2013 · Viewed 12.8k times · Source

I saw several quotes about this on the Internet but no official documentation? Can anyone tell me where I can get information about this?

Answer

Konrad Rudolph picture Konrad Rudolph · Feb 16, 2013

This isn’t supposed to be documented since it’s an implementation detail.

For instance, there is more than one implementation of SortedDictionary: there’s Microsoft’s and there’s the Mono implementation.

And the Mono implementation does, in fact, use a red-black tree in its current version (2.10.9). So does the current .NET version (you can find that out by decompiling the code, for instance by using Reflector, ildasm.exe or the built-in IL viewer in MonoDevelop).

However, this is probably going to change in the future since there are actually more efficient implementations (as B trees).

So, again: this information isn’t useful, it’s an implementation detail, and it is going to change with high probability.