Terminology

Learn all these terms:

The Wonder and Joy of Binary Trees

  1. \(\lfloor \log_2 h \rfloor\)
  2. \(2h + 1\)
  3. \(2^{h+1} - 1\)
  4. \(2^h + h\)
  5. \(h!\)

The Wonder and Joy of Binary Trees

Exercise #2

  1. \(\lceil \log_2 n \rceil\)
  2. \(\lfloor \log_2 n \rfloor\)
  3. \(\lfloor \frac{n}{2} \rfloor\)
  4. \(n\)
  5. \(2^n\)

Exercise #2

Take Home Message

Traversals

Traversals

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());
      }
    }

  }