Show / Hide Table of Contents

Class BinarySearchTree<TK, TV>

Data structure that stores items and allows fast lookup, insertion and deletion.

Inheritance
System.Object
BinarySearchTree<TK, TV>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Fusee.Jometri
Assembly: Fusee.Jometri.dll
Syntax
public class BinarySearchTree<TK, TV>
    where TK : IComparable<TK>
Type Parameters
Name Description
TK

The type of the tree's key.

TV

The type of the tree's value.

Fields

_globalRoot

The root node of the tree.

Declaration
protected Node<TK, TV> _globalRoot
Field Value
Type Description
Node<TK, TV>

Methods

BalanceTree()

Balances a given tree.

Declaration
public void BalanceTree()

DeleteNode(TK)

Deletes a node from the tree.

Declaration
public void DeleteNode(TK key)
Parameters
Type Name Description
TK key

Key of the node which is to be deleted.

FindLargestSmallerThanInBalanced(TK)

Finds the value of a node whose key is the largest, smaller than the given. Only works with a balanced tree. It may be necessary to call BalanceTree before this method.

Declaration
public TV FindLargestSmallerThanInBalanced(TK key)
Parameters
Type Name Description
TK key

The key that is used as search parameter.

Returns
Type Description
TV

FindMin()

Returns the minimum value in the tree.

Declaration
public TV FindMin()
Returns
Type Description
TV

FindMin(Node<TK, TV>)

Returns the minimum value in the tree, starting at the given node.

Declaration
protected static Node<TK, TV> FindMin(Node<TK, TV> root)
Parameters
Type Name Description
Node<TK, TV> root

The node at which to start the search.

Returns
Type Description
Node<TK, TV>

The node containing the minimum value.

FindNode(TK)

Traverses the tree to find and return a node with a certain value.

Declaration
public TV FindNode(TK key)
Parameters
Type Name Description
TK key

The key to be searched for.

Returns
Type Description
TV

InOrderTraverseTree()

Inorder traversal of the tree.

Declaration
public IEnumerable<TK> InOrderTraverseTree()
Returns
Type Description
System.Collections.Generic.IEnumerable<TK>

InsertNode(TK, TV)

Inserts a new node in a existing tree.

Declaration
public void InsertNode(TK key, TV value)
Parameters
Type Name Description
TK key

The key of the node.

TV value

Value of the node to be inserted into the tree.

PreorderTraverseTreeKeys()

Preorder traversal of the tree. Visits the root, then visits the left sub-tree, after that visits the right sub-tree. Returns the keys.

Declaration
public IEnumerable<TK> PreorderTraverseTreeKeys()
Returns
Type Description
System.Collections.Generic.IEnumerable<TK>

PreorderTraverseTreeValues()

Preorder traversal of the tree. Visits the root, then visits the left sub-tree, after that visits the right sub-tree. Returns the values.

Declaration
public IEnumerable<TV> PreorderTraverseTreeValues()
Returns
Type Description
System.Collections.Generic.IEnumerable<TV>
Generated by DocFX
GitHub Repo
Back to top