Pergunta de entrevista da empresa ZAPR Media Labs

Traverse a particular tree in optimal manner with node information present in array and indices of array representing its parent node information.