From the question it is unclear that after expanding at each level are we supposed to discard the previous list.Like for example assume n=9 as given in the problem.
After first iteration we get the list [4 ,1, 4]
Now after second iteration will the list become-
[2, 0, 2, 2, 0, 2] ? one set of 2,0,2 belong to left most 4 and another set of 2,0,2 belong to rightmost 4 in the list [4, 1, 4]. This is my first question, the second question is, in the list 4,1,4 we expand 4’s but we dont expand 1, so will this 1 be present in my final list when all elements are turned to 0 or 1. i.e will the final list contain only 0s and 1s? and if so will this list contain the 1 which was derived at level 1 i.e after expanding 9 to 4,1,4.
9 - [4,1,4]
[4,1,4] - [2,0,2,2,0,2]
[2,0,2,2,0,2] - [1,0,1,1,0,1,1,0,1,1,0,1] is this the final list? or is it this one -
[101010111011101] this list includes all ones that have been found before, this is obatined on preorder traversal of the tree.
Or if there is something else that this plz explain with sample input.
Thank you.