class node{
public:
int data;
node *left;
node *right;
};
class BFStree{
public:
void insert(int key);
void deleteNode(int key);
void inorderTraversal(node *temp);
void inorder();
node *root;
BFStree(){
root = NULL;
}
};
void BFStree::insert(int key){
node *temp = root;
while(temp!=NULL){
if(key>temp->data){
temp = temp->right;
}
else if(key<temp->data){
temp = temp->left;
}
else{
cout << "NOT ALLOWED TO HAVE SAME DATA" << temp->data << " " << key << endl;
}
}
node *temp2 = new node;
temp2->data = key;
cout << key << " inserted" << endl;
temp2->left = NULL;
temp2->right = NULL;
temp = temp2;
}
int main(){
BFStree t;
t.insert(7);
t.insert(3);
t.insert(21);
}
class node{
public:
int data;
node *lef