← All problemsSign in

Walks on the binary tree

CodeChefRating 2805Open on judge ↗

You have a perfect binary tree of height N. That is, it contains 2N+1 - 1 nodes. A path from the root to a leaf can be represented by an integer X which lies between 0 and 2N - 1 (both inclusive) as follows: Consider the N length binary representation of X. Start reading from the left, and at each bit, 0 denotes going to the left child, and 1 denotes going to the right child. For eg. if N = 2,

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start