Solution to level order traversal using BFS