Might be I am not correct but following steps can be followed to get the desired result :
1. Create a binary tree from the characters of the input string.
2. First node will contain the first character.
3. Second character will go the left of side of the first node and third character will go the right side of the first node.
Now both left and right nodes are present to the first node.
4. Take the left node fill its both child and then take right node of the first node and fill its both child
5. Follow the above approach until you finish the input string.
Once the binary tree is prepared, start retrieving nodes from level "n", level "n-1", level "n-2" and so on
The way of traversal nodes should be in order from right to left.
Example : Input string : Ahmed
Output as binary tree : A
| |
h m
| |
e d
Traversal result : d e m h A (reverse of the input string)
Another approach is to create left skewed or right skewed binary tree. We can get the same result but both left-skewed and right-skewed binary tree.
There might be another approach to solve the same problem in different ways. Please share if someone knows another ways to solve this problem.