public void Insert(int value) { if (value <= this.value) { if (left == null) { left = new BSTNode(value); } else { left.Insert(value); } } else { if (right == null) { right = new BSTNode(value); } else { right.Insert(value); } } }
public static int BinaryTreeSearch(int[] array) { var bstNode = new BSTNode(array[0], 0); for (int i = 1; i < array.Length; i++) { bstNode.Insert(array[i], i); } return(bstNode.Search(80)); }