NO NEED TO CODE JUST SHOW ON PEN AND PAPER C++ Consider the hash table that resu
ID: 3737260 • Letter: N
Question
NO NEED TO CODE JUST SHOW ON PEN AND PAPER
C++
Consider the hash table that results after the letters
A L G O R I T H M I C
have been inserted, in that order, into an initially empty table with 13 slots using linear probing. (Assume we're implementing a multi-set, so duplicate entries are permitted.) For your hash function, use h(k) = k % 13 where k is assigned as follows:
A:1 B:2 C:3 D:4 E:5 F:6 G:7 H:8 I:9 J:10
K:11 L:12 M:13 N:14 O:15 P:16 Q:17 R:18 S:19 T:20
U:21 V:22 W:23 X:24 Y:25 Z:26
What letter will be in position 10 of the array used to store the table?
A
L
G
O
R
I
T
H
M
C
that slot is empty
Explanation / Answer
A -> A = 1 1 % 13 is 1 so, A is inserted at 1 L -> L = 12 12 % 13 is 12 since slot 12 is empty, L is inserted at 12 G -> G = 7 7 % 13 is 7 since slot 7 is empty, G is inserted at 7 O -> O = 15 15 % 13 is 2 since slot 2 is empty, O is inserted at 2 R -> R = 18 18 % 13 is 5 since slot 5 is empty, R is inserted at 5 I -> I = 9 9 % 13 is 9 since slot 9 is empty, R is inserted at 9 T -> T = 20 20 % 13 is 7 slot 7 is not empty (G is already in it) Next available empty spot is at 8. so, T is inserted at 8 H -> H = 8 8 % 13 is 8 slot 8 is not empty (T is already in it) Next available empty spot is at 10. so, H is inserted at 10 M -> M = 13 13 % 13 is 0 since slot 0 is empty, M is inserted at 0 C -> C = 3 3 % 13 is 3 since slot 3 is empty, C is inserted at 3
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.