1. 程式人生 > >Full Binary Tree(有關二叉樹)

Full Binary Tree(有關二叉樹)

In computer science, a binary tree is a tree data structure in which each node has at most two children. Consider an infinite full binary tree (each node has two children except the leaf nodes) defined as follows. For a node labelled v its left child will be labelled 2 * v and its right child will be labelled 2 * v + 1. The root is labelled as 1.You are given n queries of the form i, j. For each query, you have to print the length of the shortest path between node labelled i and node labelled j.