Pregunta de entrevista de SingleStore

Generic algorithm question with a tree