// WARNING: THIS CODE HAS NOT BEEN TESTED. // IT WILL TAKE 1-2 MONTHS TO PERFECT THE CODE. // IF YOU FACE ANY ERRORS, UNEXPECTED BEHAVIOUR OR HAVE ANY SUGGESTIONS, // LET US KNOW BY CREATING AN ISSUE ON OUR KSKA GIT REPOSITORY. /* Problem Statement: Consider telephone book database of N clients. Make use of a hash table implementation to quickly look up client's telephone number. Make use of two collision handling techniques and compare them using number of comparisons required to find a set of telephone numbers. Code from Data Structures and Algorithms (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-content/DataStructuresAndAlgorithms/ */ // BEGINNING OF CODE #include #include #define max 10 using namespace std; struct client { long int iPhno; char name[20]; };//end of structure class hashtable { client ht[max]; public: hashtable() //constructor { for(int i=0;i>c.iPhno; iPos=hash(c.iPhno); if(ht[iPos].iPhno==0) { ht[iPos]=c; } else { for(int i=iPos+1;i%max!=iPos;i++) { ht[i]=c; break; } } cout<<"\n Add More:"; cin>>cAns; }while(cAns=='y' || cAns=='Y'); }//end of insert int hashtable::hash(long int key) { return(key%max); }//end of hash void hashtable::display() { cout<<"------------------------------------"; cout<<"\nSrno\tPhone number\n"; cout<<"------------------------------------\n"; for(int i=0;i>x; for(int i=0;i>s; for(int i=0;i>iCh; cout<<"\n"; switch(iCh) { case 1://insert h.insert(); cout<<"\n"; break; case 2://display h.display(); cout<<"\n"; break; case 3://search h.search(y); cout<<"\n"; break; case 4://delete h.del(s); cout<<"\n"; break; case 5://exit break; }//end of switch }while(iCh!=5);//end of do return 0; } // END OF CODE // EXPERIMENTAL CODE