LinkedIn Interview Question

Write a function to implement BFS.