#include
#include
int s0[10],s1[10],s2[10],s3[10];
int sk,mod,a,flag;
int c0=0,c1=0,c2=0,c3=0;
main()
{
int ch;
clrscr();
do
{
printf("Enter your choice:\n");
printf("1.Search the value\n2.Insert the value\n3.Delete the value\n4.Display\n5.exit\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
search();
break;
case 2:
insert();
break;
case 3:
del();
break;
case 4:
display();
break;
default:
printf("\nenter again\n");
}
}while(ch!=5);
}
insert()
{
printf("\ninsert the value \t");
scanf("%d",&sk);
mod=sk%4;
if(mod==0)
{
printf("%d is in bucket number %d at position %d",sk,mod,c0);
s0[c0]=sk;
c0++;
}
else if(mod==1)
{
printf("%d is in bucket number %d at position %d",sk,mod,c1);
s1[c1]=sk;
c1++;
}
else if(mod==2)
{
printf("%d is in bucket number %d at position %d",sk,mod,c2);
s2[c2]=sk;
c2++;
}
else if(mod==3)
{
printf("%d is in bucket number %d at position %d",sk,mod,c3);
s3[c3]=sk;
c3++;
}
}
display()
{
int j,i=1;
for(i=0;i<4;i++)
{
printf("\n bucket%d : ",i);
if(i==0)
{
for(
j=0;j
{
printf(" %d ",s0[j]);
}
}
if(i==1)
{
for(j=0;j
{
printf(" %d ",s1[j]);
}
}
if(i==2)
{
for(j=0;j
{
printf(" %d ",s2[j]);
}
}
if(i==3)
{
for(j=0;j
{
printf(" %d ",s3[j]);
}
}
}
}
search()
{
int sea,mod1=0,k;
printf("\nenter the value u want to search:\t");
scanf("%d",&sea);
mod1=sea%4;
if(mod1==0)
{
for(k=0;k
{
if(sea==s0[k])
{
printf("\n%d is present in bucket no %d at position %d",sea,mod1,k);
flag=1;
}
}
if(flag==1)
{
}
else
printf("\ndata not found");
}
if(mod1==1)
{
for(k=0;k
{
if(sea==s1[k])
{
flag=1;
printf("\n%d is present in bucket no %d at position %d",sea,mod1,k);
}
}
if(flag==1){}
else
printf("\ndata not found");
}
if(mod1==2)
{
for(k=0;k
{
if(sea==s2[k])
{
flag=1;
printf("\n%d is present in bucket no %d at position %d",sea,mod1,k);
}
}
if(flag==1){}
else
printf("\ndata not found");
}
if(mod1==3)
{
for(k=0;k
{
if(sea==s3[k])
{
flag=1;
printf("\n%d is present in bucket no %d at position %d",sea,mod1,k);
}
}
if(flag==1){}
else
printf("\ndata not found");
}
}
del()
{
int sea,mod1,m,k;
printf("\nEnter value u want to delete");
scanf("%d",&sea);
mod1=sea%4;
//printf("mod1=%d",mod1);
if(mod1==0)
{
for(k=0;k
{
if(sea==s0[k])
{
printf("\n%d is present in bucket no %d at position %d",sea,mod1,k);
flag=1;
break;
}
}
if(flag==1)
{
for(m=k;m
{
s0[m]=s0[m+1];
s0[m+1]=0;
}
c0--;
}
else
printf("\ndata not found");
}
if(mod1==1)
{
for(k=0;k
{
if(sea==s1[k])
{
flag=1;
printf("\n%d is present in bucket no %d at position %d",sea,mod1,k);
}
}
if(flag==1)
{
for(m=k;m
{
s1[m]=s1[m+1];
s1[m+1]=0;
}
c1--;
}
else
printf("\ndata not found");
}
if(mod1==2)
{
for(k=0;k
{
if(sea==s2[k])
{
flag=1;
printf("\n%d is present in bucket no %d at position %d",sea,mod1,k);
}
}
if(flag==1)
{for(m=k;m
{
s2[m]=s2[m+1];
s2[m+1]=0;
}
c2--;
}
else
printf("\ndata not found");
}
if(mod1==3)
{
for(k=0;k
{
if(sea==s3[k])
{
flag=1;
printf("\n%d is present in bucket no %d at position %d",sea,mod1,k);
}
}
if(flag==1)
{for(m=k;m
{
s3[m]=s3[m+1];
s3[m+1]=0;
}
c3--;
}
else
printf("\ndata not found");
}
}
Copyright © 2011 - All Rights Reserved - Softron.in
Template by Softron Technology