Bottom View of Binary Tree

Here is the function implemented for the bottom view of binary tree:-https://ide.codingblocks.com/s/463923, this is the question link:-https://practice.geeksforgeeks.org/problems/bottom-view-of-binary-tree/1#, please specify the error done in the code as it is giving runtime error.

hello @Sakshi2004
check now->

Input:
14 14 3 N 8 8 12 N 6 17 3 N 1 11 10 N 6 6 13 N 10 17 7 N 11 7

Its Correct output is:
7 6 7 13 11 10

And Your Code’s output is:
17 11 7 10 11 10
The answer is still wrong for this test case. and please explain the inorder traversal thing because we are maintaing a ordered map so the leftmost node should come first and according to d marked on every node we are doing that.

i had updated the code , have u checked that?
it is passing all cases.

What’s the updated code, please send it once again.

I am not getting the equal vala part? as in this test case:- 3 5 1 6 2 0 8 null null 7 4, there will be two nodes 2 and 0 which are at same level 2 and also d is same for both, i.e, 0 so what will be the output theoritically. Should not we add both the nodes here and if not then why preference to node with value 0 is given first.

ss

read this. . . . .

There is no image loading, please resend it.

ss

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.