class hash_quadratic{
public static void main(String args[]) throws Exception{
int n=11,i,k,j,flag;
int a[]=new int[11];
int hash[]=new int[11];
BufferedReader cin= new BufferedReader (new InputStreamReader(System.in));
System.out.println("enter the elements to be sorted");
for(i=0;i
hash[i]=0;
}
for(i=0;i
j=0;
while(flag!=1){
k=((2*a[i]+5)%11+j*j)%11;
if(hash[k]==0){
hash[k]=a[i];
flag=1;}
else{
j++;
}
}
}
System.out.println("hash table is");
for(i=0;i
System.out.println(hash[i]);
}
}
}
Run Here https://ideone.com/7CsuT
No comments :
Post a Comment