public class Tree public class Node public int value public Node left

 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
public class Tree
{
public class Node
{
public int value;
public Node left;
public Node right;
public Node(int v, Node l, Node r)
{
this.value = v;
this.left = l;
this.right = r;
}
}
public void Add( int value, ref Node head)
{
if (head == null)
head = new Node(value, null, null);
else
if (head.value < value)
Add(value, ref head.right);
else
Add(value, ref head.left);
}
}