Learn all these terms:
|
|
|
|
In a linked list we store a reference to one node, all other nodes are reachable by following
In a binary tree we store a reference to one node, all other nodes were reachable by following
Trace the following traversal method…
public static <E> void mystery(BinNode<E> rt) {
Queue<BinNode<E>> queue = new LQueue<>();
queue.enqueue(rt);
while (queue.length() > 0) {
BinNode<E> cur = queue.dequeue();
visit(cur);
if (cur.left() != null) {
queue.enqueue(cur.left());
}
if (cur.right() != null) {
queue.enqueue(cur.right());
}
}
}
Space, Right Arrow or swipe left to move to next slide, click help below for more details