Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D

A rooted tree has these parent→child edges: 33→62, 48→67, 15→81, 48→77, 62→46, 67→83, 77→59, 59→68, 14→25, 50→33, 33→14, 51→15, 15→50, 67→51, 83→18. The parent of a node is its 1st ancestor. Using binary lifting, which node is the 4th ancestor of node 33?

  1. A. 51
  2. B. 67
  3. C. 48
  4. D. 50

Correct answer: B. 67

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic