Infosys Interview Question

Write the code for BFS