Tree Bottom View Query

https://ide.codingblocks.com/s/102261 what is wrong with the code i am getting wrong answer for test case 2. Also i don’t understand how to take the input of this form:
Input: 1 2 3 4 5 6 7 -1 -1 -1 8 -1 -1 -1 9 -1 -1 -1 -1

Anushka u have to take level order input
u have to use a queue to insert the data
just take the first input then check for its left data and right data if -1 then no left/right child then dont push into queue ortherwise push into queue

also
static array size of 10^7 will not created in main either make it globally or allocate it dynamically

I still don’t understand how to take the input when the size of the array is not given.

u have to consider -1
when a child value is -1 then u stop its futhur child nodes

will the elements not be present in after -1?
what about inputs of the above type

first in queue insert 1 then ask for its left and right child if it is not -1 then insert it in q
2 and 3 are inserted in queue and pop 1
now ask for left and right child of 2 and similary


I have changed the code but still the 2nd test case is showing wring answer.

insert function is wrong
i will send u a level order input function
check this

node* LevelOrderInput(){
queue<node*>q;
int x;cin>>x;
node* root=new node(x);
q.push(root);
while(!q.empty()){
node* temp=q.front();
q.pop();
cin>>x;
cout<<x;
if(x!=-1){
temp->left=new node(x);
q.push(temp->left);
}
cin>>x;
if(x!=-1){
temp->right=new node(x);
q.push(temp->right);
}
}
return root;
}

first run this code with an example on a copy and see how the tree is being created i

I changed the code accordingly but the second test case is again showing Wrong-Answer. The same happens with Left Tree View. However Top Tree View Question and Vertical Order Print Challenges work fine. I haven’t checked for Right Tree View.

Please tell what is wrong with the code @phantom

check for this
20 8 22 5 3 4 25 -1 -1 10 14 -1 -1 -1 -1 -1 -1 -1 -1

in the vertical order function it is mapping 14 first and then 22. How to rectify that?

take a variable L which denotes at which level u are inserting like
u have inserted d=1 and level =1 if another comes d=1 and level =2 replace the above one