Pergunta de entrevista da empresa Bloomberg

I had a binary tree and matrix question