/Xyaneon.ComputerScience.VanEmdeBoasTrees

A .NET Standard library which provides a van Emde Boas tree implementation for educational purposes.

Primary LanguageC#MIT LicenseMIT

Xyaneon.ComputerScience.VanEmdeBoasTrees

NuGet Build Status

A .NET Standard library which provides a van Emde Boas tree implementation for educational purposes.

Usage

Constructing a tree

Once you have the library added to your solution, you can create a van Emde Boas tree using code like the following:

using Xyaneon.ComputerScience.VanEmdeBoasTrees;

// Snip...

var tree = new VanEmdeBoasTree(universe); // universe must be an int that is a power of two.

Besides being a value of two, note that the universe value you supply must also be larger than the maximum value you plan on storing in the tree.

An alternate constructor is available if you also want to supply the values to store in the tree right away:

IEnumerable<int> yourValues = new List<int>({ 1, 2, 3 });

var tree = new vanEmdeBoasTree(4, yourValues);

Tree operations

The VanEmdeBoasTree class implements the IVanEmdeBoasTree interface. Through this interface, you have access to the following standard van Emde Boas tree operations via its methods and properties:

  • Maximum
  • Minimum
  • Delete
  • Insert
  • Member
  • Predecessor
  • Successor

The maximum and minimum can be obtained in O(1) time; all the other operations take O(lg lg n) time, which is a property of the van Emde Boas tree itself.

You can easily implement your own version of a van Emde Boas tree which implements the provided IVanEmdeBoasTree interface, then compare its results against those of the provided VanEmdeBoasTree class to check its correctness using the exact same method calls.

All public code in this library is documented using XML documentation comments, which you can refer to for further usage information. These comments should also be available to you through IntelliSense or the Visual Studio Object Browser.

Solution structure

This Visual Studio 2017 solution contains two projects.

A .NET Standard 2.0 library which provides an implementation of van Emde Boas trees.

A .NET Core 2.1 unit testing project for Xyaneon.ComputerScience.VanEmdeBoasTrees using the MSTest unit testing framework.

License

This library is free and open-source software provided under the MIT license. See the LICENSE.txt file for additional information.

Additional information

The van Emde Boas tree implementation provided is based on the pseudocode presented in the "Introduction to Algorithm Design" (CLRS) book.

This library is primarily intended for educational purposes on how van Emde Boas trees work. It may be possible to create a more performant version of the code for use in actual applications; this is left as an exercise to the reader.

References

  • Wikipedia article on van Emde Boas trees
  • "Introduction to Algorithm Design" 3rd edition, by Thomas Cormen et al. ISBN: 978-0-262-03384-8. Available here from MIT Press. See chapter 20 for information specifically on van Emde Boas trees.