Pergunta de entrevista da empresa Dialogic

Depth first search related problem. First as pseudo code and then in C++