public static void Main(string[] args) { BinarySearchTree bt = createTree(); bool a = bt.contains(38); Console.WriteLine("this contains 38"); Console.WriteLine(a); bool b = bt.contains(2); Console.WriteLine("this Does not contain 2"); Console.WriteLine(b); Console.WriteLine("========================"); BinaryTree bb = new BinaryTree(); bb.createTree(); Console.WriteLine("========PreOrder======="); bb.preOrder(bb.Root); Console.WriteLine("========inOrder========="); bb.inOrder(bb.Root); Console.WriteLine(); Console.WriteLine("=====postOrder======="); bb.postOrder(bb.Root); }
public static void Main(string[] args) { BinarySearchTree binarT = createTree(); bool a = binarT.contains(8); Console.WriteLine("this contains 8"); bool b = binarT.contains(6); Console.WriteLine("this Does not contain 6"); BinaryTree bbt = new BinaryTree(); bbt.Tree(); bbt.preOrder(bbt.Root); bbt.inOrder(bbt.Root); bbt.postOrder(bbt.Root); }
static void TraverseBinarySearchTree() { BinarySearchTree binarySearchTree = new BinarySearchTree(60); Node <int> node2 = new Node <int>(25); Node <int> node3 = new Node <int>(90); Node <int> node4 = new Node <int>(10); Node <int> node5 = new Node <int>(70); Node <int> node6 = new Node <int>(120); Node <int> node7 = new Node <int>(3); Node <int> node8 = new Node <int>(131); binarySearchTree.Root.LeftChild = node2; binarySearchTree.Root.RightChild = node3; node2.LeftChild = node4; node3.LeftChild = node5; node3.RightChild = node6; node4.LeftChild = node7; node6.RightChild = node8; Console.WriteLine("Breadth First Binary Search"); List <int> breadth = binarySearchTree.traverseBinarySearch(binarySearchTree.Root); Console.WriteLine(string.Join(',', breadth)); Console.WriteLine(); Console.WriteLine("Add new nodes 40, 115, and 44: "); binarySearchTree.add(binarySearchTree.Root, 40); binarySearchTree.add(binarySearchTree.Root, 115); binarySearchTree.add(binarySearchTree.Root, 44); List <int> breadth2 = binarySearchTree.traverseBinarySearch(binarySearchTree.Root); Console.WriteLine(string.Join(',', breadth2)); Console.WriteLine(); Console.WriteLine("Does the binary search tree contains 38?"); Console.WriteLine(binarySearchTree.contains(binarySearchTree.Root, 38)); }