Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D

A rooted tree has these parent→child edges: 5→46, 73→89, 73→49, 72→21, 24→73, 46→11, 47→97, 11→24, 21→25, 72→18, 49→94, 5→72, 25→54, 10→27, 46→10, 25→65, 73→47. The parent of a node is its 1st ancestor. Using binary lifting, which node is the 2nd ancestor of node 73?

  1. A. 24
  2. B. 46
  3. C. 11
  4. D. 5

Correct answer: C. 11

The 2nd ancestor is reached by 2 parent steps from 73; binary lifting takes the bits of 2 as jumps. Off by one in the step count, or treating 2 as an absolute depth, gives the trap nodes.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic