-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpen Hashing for float.cpp
More file actions
85 lines (79 loc) · 1.24 KB
/
Open Hashing for float.cpp
File metadata and controls
85 lines (79 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <stdio.h>
#include<conio.h>
#include<stdlib.h>
const int size =10;
struct node
{
float data;
struct node *next;
} arr[10];
insert()
{
int Index;
float value;
int invalue;
printf("\nEnter the value: ");
scanf("%f",&value);
invalue=value;
Index=invalue%size;
if(arr[Index].data==-1)
arr[Index].data=value;
else
{
struct node*temp;
temp=(struct node*)malloc(sizeof(struct node));
temp ->data=value;
temp->next=NULL;
if(arr[Index].next== NULL)
arr[Index].next=temp;
else
{
struct node *curr=arr[Index].next;
while (curr->next != NULL)
{
curr=curr->next;
}
curr->next=temp;
}
}
}
search()
{
int Index,isearch;
float search;
printf("Enter the value you want to search: ");
scanf("%f",&search);
isearch=search;
Index=isearch%size;
if(search==arr[Index].data)
{
printf("Your value is found at Index %d",Index);
}
else
{
struct node* curr=arr[Index].next;
while(curr != NULL)
{
if(curr->data==search)
{
printf("value is found");
break;
}
curr=curr->next;
}
}
}
int main()
{
for(int x=0;x<size;x++)
{
arr[x].data =-1.0;
arr[x].next= NULL;
printf("\n%f",arr[x].data);
}
for(int i=0;i<size;i++)
{
insert();
}
search();
}