Sibling (binary tree)

#include<bits/stdc++.h>
using namespace std;

class node{
public:
int data;
node* left;
node* right;

node(int d){
data=d;
left=NULL;
right=NULL;
}
};
void create(node* &root){
int d;
cin>>d;
root=new node(d);

string left,right;
cin>>left;
if(left=="true"){

 //cin>>d;
 //root->left=new node(d);
 create(root->left);
}
if(left=="false"){
	root->left=NULL;

}
 cin>>right;
if(right=="true"){
	//cin>>d;
	//root->right=new node(d);
  create(root->right);
}
if(right=="false"){
	root->right=NULL;
}

}

void sibling (node* root){
if(!root->left && !root->right){
cout<data;
return;
}
// if(root==NULL){
// return;
// }
sibling(root->left);
sibling(root->right);
return;
}

int main(){

node* root=NULL;
 create(root);
 sibling(root);

return 0;

}

it shows segmentation fault

hi @kumarakash121005, do save your code on CB online and send link big codes are not readable at this portal (https://ide.codingblocks.com)

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.