Posts

Binary Tree

Image
  A tree whose elements have at most 2 children is called a binary tree. Since each element in a binary tree can have only 2 children, we typically name them the left and right child. A Binary Tree node contains following parts. Data Pointer to left child Pointer to right child class Node {      int key;      Node left, right;        public Node( int item)      {          key = item;          left = right = null ;      } } public static void Main(String[] args)      {          BinaryTree tree = new BinaryTree();            /*create root*/          tree.root = new Node(2);            /* following is the tr...