Linear Probing - #include<stdio.h>...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <stdio.h> #include <conio.h> /* RISHI AGARWAL       HASHING : LINEAR PROBING    ROLL NO 02    SE CMPN A  */ int hashsearch(int a[],int x,int n) {   int index,start;   index=x%n;   if(a[index]==x)    return index;   else if(a[index]==-1)    return -1;   else   {start=index;    do    { index=(index+1)%n;    if(a[index]==x)     return index;    else if(a[index]==-1)     break;    }while(index !=start);    return -1;   } } void main() {int hsh[10],i,x,index,k,n,z;  clrscr();  printf("\tHASHING USING LINEAR PROBING\n");  printf("Enter the size of the table & no of elements");  scanf("%d%d",&n,&z);  printf("\tHASH table creation\n");  for(i=0;i<n;++i)   hsh[i]=-1;  printf("Enter the numbers : ");  for(i=1;i<=z;++i)  { scanf("%d",&x);    index=x%n;    while(hsh[index]!=-1)     index=(index+1)%n;    hsh[index]=x;  }  printf("\tHash Table\n");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/25/2010 for the course CMPN SEM4 taught by Professor Thakur during the Spring '07 term at University of Mumbai.

Page1 / 2

Linear Probing - #include&lt;stdio.h&gt;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online