Problem 2509 · Hard

Cycle Length Queries in a Tree

In a perfect binary tree with heap numbering, the path between two labels is found by halving the larger label until they meet.

Open the interactive visualisation