← Microsoft questions

Find all ancestors of a node in a binary tree

Filed under Microsoft

Given the root of a binary tree and a target node value, find and return the values of all ancestors of the target node, ordered from the parent up to the root (or root down to parent).

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 Microsoft questions

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