← Amazon questions
CodingReported in a candidate post, Aug 2012

Ancestor Matrix

Filed under Amazon

Given a binary tree with N nodes, populate an N x N boolean matrix where matrix[A][B] = 1 if node A is an ancestor of node B, and 0 otherwise.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Amazon questions

Collected from public candidate posts and coding forums. Updated Nov 2026.