Pseudocode written for bfs