Write a C program to implement all the functions of a dictionary (ADT) using hashing.

Globally declare
int a[10];
void display();
void put(int data,int key);
void probing(int key,int data);

1. Algorithm:
void set()
Step1: Start
Step2: Declare i
Step3: repeat for(i=0;i<10;i++)
Step4: a[i]=0
Step5: stop

2. Algorithm: 
void accept(int data)
Step1: Start
Step2:declare int key=data%10
Step3: call sub function put(data,key)
Step4: Stop

3. Algorithm:
void put(int data,int key)
Step1: Start
Step2: check if(a[key]==0) got step3 otherwise step4
Step3: a[key]=data
Step4: lse
Step5:call sub function probing(key,data)
Step6: Stop

4. Algorithm:
void probing(int key,int data)
Step1: start
Step2: repeat while(a[key]!=0) step3
Step3: key++
Step4: a[key]=data
Step5: Stop

5. Algorithm: 
void search(int key)
Step1: Start
Step2: declare int i,index
Step3: Assign index=(key%10)
Step4: repeat for(i=0;i<10;i++) upto step 7
Step5: Check if(i==index) upto step 7
Step6: print element found at is i, a[i]
Step7: exit(0)
Step8: print element not found
Step9: stop

6. Algorithm: 
void delete(int key)
Step1: Start
Step2: Declare int i,index
Step3: Assign index=(key%10);
Step4: repeat for(i=0;i<10;i++) upto step 9
Step5: Check if(i==index) upto step 9
Step6: print deleted element is a[i]
Step7: a[i]=0;
Step8: call sub function display()
Step9: exit(0)
Step10: print element not exist
Step11: stop

7. Algorithm:
void display()
Step1: Start
Step2: Declare int i;
Step3: print display the list
Step4: for(i=0;i<10;i++)
Step5: print,i,a[i]
Step6: Stop

8. Algorithm:
void main()
Step1: Start
Step2: Declare i,b[20],n,ch,key;
Step3: repeat do
Step4:Read choice 1.create 2.search 3.delete 4.display 5.exit
Step5: switch(ch)
Step6: case 1: set();
Read no of elements n
Read the elements b[i]
call subfunction accept(b[i]) and display()
case 2:
Read the key to searched
call subfunction search(key)
case 3:
Read the key to be deleted:
call subfunction delete(key)
case 4:
call subfunction display()
case 5:call subfunction exit(0)
Step7: end of switch
Step8: end of do -while(1)
Step9: stop

Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:


Mukesh Rajput