Exemplo n.º 1
0
        public static void PreOrderIterative(BST tree)
        {
            if (tree != null)
            {
                Stack <BST> stack   = new Stack <BST>();
                BST         current = tree;
                stack.Push(current);
                while (current != null && stack.Count > 0)
                {
                    BST nodeToPrint = stack.Pop();
                    Console.WriteLine(nodeToPrint.data);

                    if (current.right != null)
                    {
                        stack.Push(current.right);
                    }
                    if (current.left != null)
                    {
                        stack.Push(current.left);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public static void PostOrderIterative(BST tree)
 {
 }