Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D

A rooted tree has these parent→child edges: 13→29, 25→79, 65→24, 86→96, 24→13, 13→51, 25→94, 86→25, 17→65, 2→17, 92→18, 93→86, 75→93, 79→92, 65→75. The parent of a node is its 1st ancestor. Using binary lifting, which node is the 3rd ancestor of node 96?

  1. A. 75
  2. B. 93
  3. C. 65
  4. D. 2

Correct answer: A. 75

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic