js401-reading

trees

pre order

output <- root.value
if root.left is not null
  preOrder(root.left)
if root.right is not null
  preorder(root.right)

breadth first

queue breadth <- new Qeueue()
breadth.enqueue(root)

while breadth.peek()
  node front = breadth.dequeue()
  output <- front.value

  if front.left is not null
    breadth.enqueue(front.left)

  if front.right is not null
    breadth.enqueue(front.right)

binary search trees