Levelorder

Hide text Hide pseudo-code

Traverse the following binary tree in level order.

void traverse_levelorder(link t)
{
  queue.put(t);
  do {
    t = queue.get();
    if (t != null) {
      visit(t);
      queue.put(t.getLeft());
      queue.put(t.getRight());
    }
  } while (!queue.empty());
}


  Created Fri Oct 30 13:52:51 EET 2009 - Powered by SVG-hut