Appian interview question

In DSA, a question on a modified BFS algorithm was asked