MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CPP/hashing/quadratic_probing.cpp:7–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5 return key % 13;
6}
7int main()
8{
9 int a[] = {26, 28, 31, 34, 35, 25, 31, 31, 31, 25};
10 int h[13];
11 int n = 13;
12 for (int i = 0; i < 13; i++)
13 h[i] = -999;
14 for (int i = 0; i < 10; i++)
15 {
16 if (h[hashfunction(a[i])] != -999)
17 {
18 int j = 1;
19 int pcount = 1;
20 int k;
21 k = hashfunction(a[i]);
22 while (pcount < n / 2 && h[(k + j) % 13] != -999)
23 {
24 k = (k + j) % 13;
25 cout << a[i] << "->" << k << " ";
26 j = j + 2;
27 pcount++;
28 }
29 cout << endl;
30 if (h[(k + j) % 13] == -999)
31 h[(k + j) % 13] = a[i];
32 }
33 else
34 h[hashfunction(a[i])] = a[i];
35 }
36 for (int i = 0; i < 13; i++)
37 cout << h[i] << " ";
38}

Callers

nothing calls this directly

Calls 1

hashfunctionFunction · 0.85

Tested by

no test coverage detected