Skip to content
Azhimathi Mayam logoDSA Study HubPCCST303 · KTU · S3
B.Tech S3 (S) Examinations May 2026 (2024 Scheme)QP 06PCCST303112504Part B · Q16a6 marksCO4Module 4asked in 2 papers

Question 16a

Given the values 45,36,19,58 and 10 and a hash table of size 13. Show the resultant table after inserting values in the given order by using hash function h(k)=k%13 with each of the following collision strategies. i) Linear Probing ii) Quadratic Probing iii) Double hashing with secondary hash function h'(k)=7-k%7

Topics: Collision resolution: linear probing, quadratic probing, double hashing

Watch this exact question run

Loading visualizer…

Other parts: Quadratic probingDouble hashing

Solution

Assumptions:
  • Quadratic: (h + i²) mod 13. Double hashing: (h + i·h′(k)) mod 13 with h′(k) = 7 − (k mod 7).
Key4536195810
k mod 136106610
h′(k) = 7 − k mod 746254
i) Linear probing (generated)checked by code
KeyHome h(k)ProbesStored at
456(6 + 0) mod 13 = 66
3610(10 + 0) mod 13 = 1010
196(6 + 0) mod 13 = 6 → (6 + 1) mod 13 = 77
586(6 + 0) mod 13 = 6 → (6 + 1) mod 13 = 7 → (6 + 2) mod 13 = 88
1010(10 + 0) mod 13 = 10 → (10 + 1) mod 13 = 1111

Final table — 0: — | 1: — | 2: — | 3: — | 4: — | 5: — | 6: 45 | 7: 19 | 8: 58 | 9: — | 10: 36 | 11: 10 | 12: —

ii) Quadratic probing (generated)checked by code
KeyHome h(k)ProbesStored at
456(6 + 0²) mod 13 = 66
3610(10 + 0²) mod 13 = 1010
196(6 + 0²) mod 13 = 6 → (6 + 1²) mod 13 = 77
586(6 + 0²) mod 13 = 6 → (6 + 1²) mod 13 = 7 → (6 + 2²) mod 13 = 10 → (6 + 3²) mod 13 = 22
1010(10 + 0²) mod 13 = 10 → (10 + 1²) mod 13 = 1111

Final table — 0: — | 1: — | 2: 58 | 3: — | 4: — | 5: — | 6: 45 | 7: 19 | 8: — | 9: — | 10: 36 | 11: 10 | 12: —

iii) Double hashing (generated)checked by code
KeyHome h(k)ProbesStored at
456(6 + 0×4) mod 13 = 66
3610(10 + 0×6) mod 13 = 1010
196(6 + 0×2) mod 13 = 6 → (6 + 1×2) mod 13 = 88
586(6 + 0×5) mod 13 = 6 → (6 + 1×5) mod 13 = 1111
1010(10 + 0×4) mod 13 = 10 → (10 + 1×4) mod 13 = 11

Final table — 0: — | 1: 10 | 2: — | 3: — | 4: — | 5: — | 6: 45 | 7: — | 8: 19 | 9: — | 10: 36 | 11: 58 | 12: —

How to write it in the exam

IndexLinearQuadraticDouble hashing
0———
1——10
2—58—
3–5———
6454545
71919—
858—19
9———
10363636
11101058
12———

Double hashing details: 19 → 6 occupied → (6 + 1·2) = 8. 58 → 6 occupied → (6 + 1·5) = 11. 10 → 10 occupied → (10 + 1·4) mod 13 = 1.

How this answer was verified
  • Hand computation
  • tests/hashing-search.test.ts
  • hashing_open_addressing.c differential test

Similar questions