forked from TheAlgorithms/C-Sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinarySearchTreeNode.cs
30 lines (26 loc) · 1.01 KB
/
BinarySearchTreeNode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
namespace DataStructures.BinarySearchTree;
/// <summary>
/// Generic node class for BinarySearchTree.
/// Keys for each node are immutable.
/// </summary>
/// <typeparam name="TKey">Type of key for the node. Keys must implement IComparable.</typeparam>
public class BinarySearchTreeNode<TKey>
{
/// <summary>
/// Initializes a new instance of the <see cref="BinarySearchTreeNode{TKey}" /> class.
/// </summary>
/// <param name="key">The key of this node.</param>
public BinarySearchTreeNode(TKey key) => Key = key;
/// <summary>
/// Gets the key for this node.
/// </summary>
public TKey Key { get; }
/// <summary>
/// Gets or sets the reference to a child node that precedes/comes before this node.
/// </summary>
public BinarySearchTreeNode<TKey>? Left { get; set; }
/// <summary>
/// Gets or sets the reference to a child node that follows/comes after this node.
/// </summary>
public BinarySearchTreeNode<TKey>? Right { get; set; }
}