Tree bottom view

https://ide.codingblocks.com/s/178640 code is showing wrong answer for 3rd testcase

@Ajitverma1503 Consider the case:
20 8 22 5 3 4 25 -1 -1 10 14 -1 -1 -1 -1 -1 -1 -1 -1

Expected Output:
5 10 4 14 25

Your Output:
5 10 4 22 25

Refer this:

In the code that was mentioned in the link you provided.I have a query that for the testcase:
20 8 22 5 3 4 25 -1 -1 10 14 -1 -1 -1 -1 -1 -1 -1 -1
3 and 4 are in the same level ,
so,0 has 3 pair (20,1) (3,3) (4,3)
so how it take 4 as the ans:
link of code : https://ide.codingblocks.com/s/119779

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

my doubt is not clear

1 Like

bottom

You can follow this approach

in the code that was mentioned in the link you provided.I have a query that for the testcase:
20 8 22 5 3 4 25 -1 -1 10 14 -1 -1 -1 -1 -1 -1 -1 -1
3 and 4 are in the same level ,
so,0 has 3 pair (20,1) (3,3) (4,3)
so how it take 4 as the ans:
link of code : https://ide.codingblocks.com/s/119779

the tree will be like
20
/
8 22
/ \ /
5 3 4 25
/
10 14

3 and 4 are on the same level but 4 is considered because its on the right side

@Ajitverma1503 sorry the spacing got really messed up, but i am sure you can visualise the tree on your own. If you are confused i can share a picture with you

please mark your doubt as resolved if you are satisfied