Thoughtworks Interview Question

BFS, DFS