예제 #1
0
 public void TraverseTree()
 {
     if (parentNode != null)
     {
         parentNode.TraverseTree();
     }
 }
예제 #2
0
        public void TraverseTree()
        {
            //fist we go to the left and this function will travel allll the way to the leftmost (smallest) node and begin to print out data and call recursively to hit each node in the tree
            if (left != null)
            {
                left.TraverseTree();
            }
            //print root node
            Console.Write(data + " ");

            //then go right node which will print itself as both its children will be null
            if (right != null)
            {
                right.TraverseTree();
            }
        }