private void AddR(ref BSTNode N, int value) { if (N == null) { BSTNode newNode = new BSTNode(value); N = newNode; } else if(value < N.Data) { AddR(ref N.left, value); } else { AddR(ref N.right, value); return; } }
public string Print(BSTNode N, ref string s) { if (N == null) { N = head; } if (N.left != null) { Print(N.left, ref s); s = s + N.Data.ToString() + " "; } else { s = s + N.Data.ToString() + " "; } if (N.right != null) { Print(N.right, ref s); } return s; }
public BSTree() { head = null; }
public BSTree(int initial) { head = new BSTNode(initial); }
public BSTNode(int data) { this.Data = data; this.left = null; this.right = null; }