Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Binary Search Tree implementation in .NET 4?

I'm looking for a built-in Binary Search Tree implementation in .NET 4. Is there one?

like image 606
Micah Avatar asked Oct 12 '10 14:10

Micah


People also ask

How is a binary search tree implemented C#?

To find an element in a Binary Search Tree, we first need to compare the element with the root node; if it matches then we have the right node otherwise we need to check the left or right. The C# implementation of that same is as follows. The following is the test result of the implementation.

What is a binary tree in C#?

A binary tree is a tree in which each node has exactly two children, either of which may be empty. For example, the following is a binary tree: Note that some of the nodes above are drawn with only one child or no children at all. In these cases, one or both children are empty.

How binary search tree is implemented?

Insertion in Binary Search treeTo insert an element in BST, we have to start searching from the root node; if the node to be inserted is less than the root node, then search for an empty location in the left subtree. Else, search for the empty location in the right subtree and insert the data.

Are binary trees implemented?

Binary Tree ImplementationA Binary tree is implemented with the help of pointers. The first node in the tree is represented by the root pointer. Each node in the tree consists of three parts, i.e., data, left pointer and right pointer. To create a binary tree, we first need to create the node.


2 Answers

The SortedDictionary<K,V> class uses a Tree, is that what you're after?

See this SO answer for a discussion.

like image 53
Henk Holterman Avatar answered Sep 27 '22 21:09

Henk Holterman


You could use SortedDictionary<TKey, TValue>

like image 24
Steve Townsend Avatar answered Sep 27 '22 20:09

Steve Townsend