public void InOrder(Node theRoot)
 {
     if (theRoot != null)
     {
         InOrder(theRoot.Left);
         theRoot.DisplayNode();
         InOrder(theRoot.Right);
     }
 }
Esempio n. 2
0
 public void PostOrder(Node theRoot)
 {
     if (!(theRoot == null))
     {
         PostOrder(theRoot.Left);
         PostOrder(theRoot.Right);
         theRoot.DisplayNode();
     }
 }
		public void InOrder(Node theRoot)
		{
			if(theRoot != null)
			{
				InOrder (theRoot.Left);
				theRoot.DisplayNode ();
				InOrder (theRoot.Right);
			}
		}
Esempio n. 4
0
 public void PostOrderTraversal(Node node)
 {
     if (node != null)
     {
         PostOrderTraversal(node.Left);
         PostOrderTraversal(node.Right);
         node.DisplayNode();
     }
 }
Esempio n. 5
0
 void PrintGivenLevel(Node node, int level)
 {
     if (node == null)
     {
         return;
     }
     if (level == 1)
     {
         node.DisplayNode();
     }
     else
     {
         PrintGivenLevel(node.Left, level - 1);
         PrintGivenLevel(node.Right, level - 1);
     }
 }
Esempio n. 6
0
        public int FindNode(int key)
        {
            Node currentNode = Root;

            //if (currentNode.Data == key)
            //    return currentNode;

            while (currentNode.Data != key)
            {
                currentNode = key < currentNode.Data ? currentNode.Left : currentNode.Right;
                if (currentNode == null)
                {
                    return(0);
                }
            }
            currentNode.DisplayNode();
            return(1);
            //return currentNode.Data;
        }