Ocient interview question

Asked a question to implement BFS