0% found this document useful (0 votes)
27 views2 pages

Linear Probing Hashtable

Uploaded by

M Yasin Memon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Linear Probing Hashtable

Uploaded by

M Yasin Memon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <stdio.

h>
#include <stdlib.h>
struct node
{
int data;
int key;
};
/* run this program using the console pauser or add your own getch, system("pause")
or input loop */
int hashkey(int size,int input)
{
return input%size;
}
void insert(int key,int size,int arr[size],int input)
{
while(15)
{
if(arr[key]==-1)
{
arr[key]=input;
break;

}
if(key<size)
key++;
else
key=0;

}
int main(int argc, char *argv[]) {

int input_size;
printf("give the size of your elements\n");
scanf("%d",&input_size);
int arr[input_size];
int i;
for(i=0;i<input_size;i++)
{
arr[i]=-1;
}

printf("input the elements\n");

for(i=0;i<input_size;i++)
{

int input;
scanf("%d",&input);
int key=hashkey(input_size,input);
insert(key,input_size,arr,input);

}
//printing the elements in hash table
for(i=0; i<input_size; i++)
{
printf("%d\n",arr[i]);
}

return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy