hey these are functions to tree top view .
can you please tell my why it is showing wrong output for a few test cases.
Tree top view question
Hello @Dhruv-Miglani-2090236747707980,
Your Code will fail for the test cases like:
____________1
_____2_____________3
____________4______________5
___________________6
___________________________7
__________________________________8
Description:
1 has two childrens 2 and 3
2: 4 as right child
3: 5 as right child
4: 6 as right child
5: no child
6: 7 right child
7: 8 right child
8: no child
Your code will print:
2 1 6 7 8
Expected Output:
2 1 3 5 8
Explanation:
During the recursive call, your code will traverse the tree in the following order
1->2->4->6->7->8->7->6->4->2->1->3->5->3->1
So, for l=1 and 2, m[l].second[0] will contain 6 and 7 resp.
Hope, this will help.
Give a like if you are satisfied.
Thanks a lot ,that was really helpful.
Anytime @Dhruv-Miglani-2090236747707980,
Please, mark it as resolved if you have no more questions to ask related to this doubt.