Posts

Showing posts from May 4, 2018

Telephone Directory Using BST

Source Code: #include <iostream> #include <string> using namespace std; struct phone{  int Num;  int code; string address; string name; phone*right; phone*left; };phone*root=NULL; phone*nodeptr=NULL; //insert void insert(string nme,string add, int phno,int Code) { phone*p=new phone; p->name=nme; p->address=add; p->Num=phno; p->code=Code; p->right=NULL; p->left=NULL; if(root==NULL) { root=p; cout<<"PHone nUmber is saved \n"; } else {       nodeptr=root; while(nodeptr!=NULL) { if(phno<nodeptr->Num) { if(nodeptr->left!=NULL) { nodeptr=nodeptr->left; } else { nodeptr->left=p; cout<<"PHone nUmber is saved \n"; break; } } else if(phno>nodeptr->Num) { if(nodeptr->right!=NULL) { nodeptr=nodeptr->ri...