Practical 1
Practical 1
shailesh Roll No :- 6 0
Batch :- S13
Practical 1
Program
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.*/
#include<iostream>
#include<string.h>
struct node
int v;
node* next;
}*HashTable[10];
class hashing
public:
hashing()
int HashFunction(int v)
temp->next=NULL;
temp->v=x;
return temp;
void display()
temp=HashTable[i];
cout<<"a["<<i<<"] : ";
while(temp !=NULL)
cout<<" ->"<<temp->v;
temp=temp->next;
cout<<"\n";
int searchElement(int v)
if (entry->v==v)
cout<<hash_val<<" : "<<entry->v<<endl;
flag = true;
entry = entry->next;
if (!flag)
return -1;
void deleteElement(int v)
return;
if(entry->v==v)
return;
while ((entry->next)->v != v)
entry = entry->next;
entry->next=(entry->next)->next;
}
void insertElement(int v)
if (temp == NULL)
HashTable[hash_val] =head; //if temp null then insert head node in that position
else
temp = temp->next;
temp->next =head; // when found null then insert head node in that position
};
int main()
int data,search,del;
hashing h; //object
do
switch(ch)
cin>>data;
h.insertElement(data);
break;
case 2:h.display();
break;
cin>>search;
if (h.searchElement(search) == -1)
continue;
break;
cin>>del;
h.deleteElement(del);
cout<<"Phno. Deleted"<<endl;
break;
}while(ch!=5);
return 0;
}
Output