Pergunta de entrevista da empresa WD

Graph and tree integrated question