Data Structures & AlgorithmsModerateICPC regional · Codeforces Div2 D
A rooted tree has these parent→child edges: 22→20, 20→50, 22→55, 55→48, 75→24, 48→75, 75→17, 24→10. The parent of a node is its 1st ancestor. Using binary lifting, which node is the 3rd ancestor of node 17?
- A. 48
- B. 55
- C. 22
- D. 75
Correct answer: B. 55
The 3rd ancestor is reached by 3 parent steps from 17; 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.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- A rooted tree has these parent→child edges: 33→59, 27→38, 59→27, 25→85, 78→33, 85→76, 27→25. The parent of a node is its 1st ancestor…
- A rooted tree has these parent→child edges: 10→9, 81→72, 97→16, 85→10, 81→45, 73→40, 6→37, 9→6, 97→81, 45→73, 73→85, 37→30. The parent of…
- A rooted tree has these parent→child edges: 57→55, 95→57, 85→20, 62→95, 35→24, 20→62, 85→31, 57→9, 62→35. The parent of a node is its 1st…
- A rooted tree has these parent→child edges: 82→60, 39→52, 47→84, 84→58, 84→40, 62→39, 39→32, 84→67, 52→79, 79→47, 18→82, 62→18. The parent…
- A rooted tree has these parent→child edges: 7→76, 73→25, 25→89, 89→95, 23→62, 76→79, 69→1, 7→73, 79→33, 1→41, 23→69, 1→7, 25→49. The…
- A rooted tree has these parent→child edges: 42→80, 60→32, 1→58, 14→38, 38→25, 60→14, 90→16, 25→1, 32→90, 90→98, 90→42. The parent of a…