Exemplo n.º 1
0
        public void buildTree()
        {
            int[] arr = { 5, 2, 8, 1, 9, 6, 3, 7, 4, 10 };

            foreach (int i in arr)
                root = insert(root, i, null);
        }
Exemplo n.º 2
0
        //Pass root of the current binary tree
        public InOrderIterator(Node root)
        {
            while (root.left != null)
                root = root.left;

            next = root;    //While initializing the iterator, set next node to first node of inorder traversal
        }
Exemplo n.º 3
0
 public Node(int data, Node left, Node right, Node parent)
 {
     this.data = data;
     this.left = left;
     this.right = right;
     this.parent = parent;
 }
Exemplo n.º 4
0
 private Node MinNode(Node node)
 {
     if (node == null)
         return node;
     while (node.left != null)
         node = node.left;
     return node;
 }
Exemplo n.º 5
0
 public Node insert(Node node, int data)
 {
     if (node == null)
         return new Node(data);
     else {
         if (node.data < data)
             node.right = insert(node.right, data);
         else
             node.left = insert(node.left, data);
         return node;
     }
 }
Exemplo n.º 6
0
 private void inorderSucc()
 {
     if (next.right != null)
     {
         next = MinNode(next.right);
     }
     else
     {
         Node parent = next.parent;
         while (parent != null && parent.right == next)
         {
             next = parent;
             parent = next.parent;
         }
         next = parent;
     }
 }
Exemplo n.º 7
0
 public Node(int data, Node parent)
     : this(data, null, null, parent)
 {
 }
Exemplo n.º 8
0
 private bool InorderIter(Node node)
 {
     if (node != null)
     { }
 }
Exemplo n.º 9
0
 public Node(int data, Node left, Node right)
 {
     this.data = data;
     this.left = left;
     this.right = right;
 }