Quiz 2

[Me] | Nov 21, 2024 min read

Answer 1

image

Answer 2

image image

Answer 3

Initial: 90, 57, 25, 13, 11, 9, 17, 1, 2, 3

  1. 90 <-> 3: 3, 57, 25, 13, 11, 9, 17, 1, 2, [90]
  2. 57 <-> 2: 3, 2, 25, 13, 11, 9, 17, 1, [57, 90]
  3. 25 <-> 1: 3, 2, 1, 13, 11, 9, 17, [25, 57, 90]
  4. 17 <-> 13: 3, 2, 1, 13, 11, 9, [17, 25, 57, 90]
  5. 13 <-> 9: 3, 2, 1, 9, 11, [13, 17, 25, 57, 90]

Answer 4

Initial coff. Values (Signified in matrix format)

[2  -2   0 | -6]
[1  -1   1 |  1]
[0   3  -2 | -5]

Row2 - (1/2)Row1

[2  -2   0 | -6]
[0   0   1 |  4]
[0   3  -2 | -5]

Swap R2 and R3 (since R2 has zeros in first two positions):

[2  -2   0 | -6]
[0   3  -2 | -5]
[0   0   1 |  4]

R2 = R2 - 0R1 (already 0 in first position)

[2  -2   0 | -6]
[0   3  -2 | -5]
[0   0   1 |  4]

Back substitution: z = 4

y = (-5 + 2z)/3 = 1

x = (-6 + 2y)/2 = -2

Final answer: x = -2, y = 1, z = 4

Answer 5

image

Answer 6

a

Hashes

xh(x)
151
173
81 -> 2
232 -> 3 -> 4
33 -> 4 -> 5
55 -> 6
idxValues
0
115
28
317
423
53
65

No overflow

c

Reference h = (h1(k) + i*h2(k))%n

Hashes

xh(x)h2(x)
151
173
812
232
331 -> 4
551 -> 6
idxValues
0
115
223
317
43
58
65

No overflow

comments powered by Disqus