Given the root of a complete binary tree, with root labeled as 1, its left & right children labeld as 2 & 3, and so on and so forth. Question is to find the path of given node index from root. Required time complexity is O(logn).
Example 1:
1
/ \
2 3
/ \
4 5
Given node index 5, path is [1,2,5].Example 2:
1
/ \
2 3
/ \
4 5
Given node index 6, it does not exist in the tree, so output [].