Pearson interview question

Write the code of BFS.