Given a rooted directed tree with $N$ nodes labeled from $0$ to $N-1$, generate an $N \times N$ connectivity/reachability matrix using preorder traversal. Entry `matrix[u][v] = 1` if node $v$ is…
You've read your 3 free write-ups
Sign up free to keep reading. Your account opens the first 10 questions of every company.