.NET Built-in AVL-Tree?

Tamer Shlash picture Tamer Shlash · Jan 7, 2012 · Viewed 7.5k times · Source

Is there a built in AVL Tree in the .NET libraries?

I searched but didn't find any.

  • If there is, then where? what namespace?
  • If not, is there any good implementation for AVL Trees in C#?
  • If also not! then is there an easy way to get it done? I know how it works and have built one in native C++ before, but now I have no time and am afraid of bad performance if I did it myself.

Answer

Josef Pfleger picture Josef Pfleger · Jan 7, 2012

You can use a System.Collections.Generic.SortedSet<T>. I think it is implemented using a red-black tree which is very similar to an AVL tree.