Interview Question

Software Development Engineer II Interview Redmond, WA

BFS on a binary tree

Answer

Interview Answer

1 Answer

0

fun bfs(t,k)
  if (t is null) return not-found
  if (t.key is k) return t
  if (t is leaf)
  else
      r = bfs(t.left,k)
      if (r is not-found)
         r = bfs(t.right,k)
      return r

Anonymous on Aug 6, 2010

Add Answers or Comments

To comment on this, Sign In or Sign Up.