Search code examples
treemanaged-code

Tree Structures


What are the benefits or advantages to using a tree structure in a managed language or framework over flat structures provided by said language or framework, aka .NET, and are there any libraries for such a structure?


Solution

  • The advantages are the same as those for a tree structure in any language. Take a look at the Wikipedia article on balanced binary search trees. Balanced trees get you logarithmic insert and access time, and they keep elements sorted.

    The most commonly used application of tree structures is for sorted maps and sets. In .NET, take a look at SortedDictionary, which uses a balanced search tree.

    I'm assuming this is what you're talking about because it's the most common kind of tree in application programmer land, but trees are used for all sorts of things in computer science. Take a look at the more general article on tree data structures if you want more on this.