Reverse Pre-order Traversal
CodeChefOpen on judge ↗
One day Abhinav was teaching little Shark about data structures and algorithms related to trees. He told that given a rooted tree T containing N nodes, numbered from 1 to N, rooted at node 1. Pre-order array of the tree can be obtained by doing pre-order depth first search on the tree, starting from node 1 and recursively visiting the subtrees rooted at the children of the root. For example, given
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.
Sign in to chat with the tutor and save your progress.
Sign in to start