#include <bits/stdc++.h>
using namespace std;
class node{
public:
int data;
nodeleft;
noderight;
//constructor
node(int d){
data=d;
left=NULL;
right=NULL;
}
};
nodebuildtree(){ //fuction returns address of root node
int d;
cin>>d;
if(d==-1)
return NULL;
//create new node
noderoot=new node(d);
root->left=buildtree();
root->right=buildtree();
return root;
}
void printpre(noderoot){
if(root==NULL)
return;
cout<data;
printpre(root->left);
printpre(root->right);
}
int main(){
noderoot=buildtree();
cout<data;
}
There is no output please debug this code
@Detoxo_16 Please save your code on ide.codingblocks.com and share its link. I will make the required changes.
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.