/bin/run.sh: line 4: 18 Segmentation fault (core dumped) ./exe

getting error

@toshitvarshney11 hey let me check your code.

@toshitvarshney11 hey your logic for top view is correct,but for building tree it is given that input of tree is level wise so take level wise input as shown below:
node* buildTreeLevelWise(){

int d;
cin>>d;

node*root = new node(d);
queue<node*> q;
q.push(root);

while(!q.empty()){

	node*f = q.front();
	q.pop();
	int c1,c2;
	cin>>c1>>c2;

	if(c1!=-1){
		f->left = new node(c1);
		q.push(f->left);
	}
	if(c2!=-1){
		f->right = new node(c2);
		q.push(f->right);
	}
}
return root;

}

Sir can you explain me the code plzz

Sir please help with the code how to build tree level wise

@toshitvarshney11 hey just like level order traversal of tree we push root in queue then we pop the item and make new node and attach it to left of current node and then similiarly for right,in this way tree is created.

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.