bt take input
binaryTree <int>* takeInput(){
int rootData;
cout<<"Enter data: ";
cin>>rootData;
if (rootData==-1){
return NULL;
}
binaryTree<int>* root=new binaryTree<int>(rootData);
binaryTree<int>* leftchild=takeInput();
binaryTree<int>* rightchild=takeInput();
root->left=leftchild;
root->right=rightchild;
return root;
}
//1 2 4 -1 -1 5 6 -1 -1 7 -1 -1 3 8 -1 -1 -1
Comments
Post a Comment