23 System.err.println(
"enter with node="+node);
25 System.out.println(
"output "+node);
30 System.err.println(
"leave with node="+node);
42 System.out.println(
"output "+node);
58 System.out.println(
"output "+node);
91 System.err.print(
" ");
94 public static void main(String[] args) {
97 System.out.println(
"recursive traversal:");
101 System.out.println(
"iterative traversal:");
103 System.out.println();
105 System.out.println(
"level order traversal:");
BinaryTree< T > getLeft()
get left child or null
BinaryTree< T > getRight()
get right child or null)
boolean is_empty()
Is queue empty?
boolean is_empty()
Is stack empty?
example: transform recursive preoder traversal to iterative algorithm
static void indent(int n)
indent output on System.err
static void level_order_traversal(BinaryTree< String > root)
implement level-order traversal
static void main(String[] args)
static void recursive_traversal(BinaryTree< String > node, int level)
recursive algorithm
static BinaryTree< String > exampleTree()
generate some tree
static void iterative_traversal(BinaryTree< String > root)
iterative algorithm
A queue that outputs messages on enqueue and dequeue.
void enqueue(T x)
Enqueue element at end of queue.
T dequeue()
Remove front element from queue.
A stack that outputs messages on push and pop.
T pop()
Pop element from stack.
void push(T x)
Push x onto stack.
utilities (not related to AuD lecture)
AuD lecture: Data structures, algorithms, examples.