Given the hash function h(k) = k mod 12,answer the following question on hashing
a) Insert the following keys into the hash table below. Usethe linear probing collision resolutiontechnique when appropriate. Note: Implementation of thistechnique includes wrapping around the array when you run out ofslots at the end.
Insert keys *: 18, 41, 22, 44, 58, 32, 34
Remove keys *: 22
Insert keys *: 73, 20
(*Assume associated values will be added/removed; forsimplicity we’re leaving that out.)
b) How many keys (in total) and which ones caused an initialcollision when being inserted (list them with commas)?__________
(Note, count only the initial collision if there is one.Don’t count subsequent collisions to place the key.)
What is the worst-case time complexity of this code? def fcn(arr): n = len(arr) swapped = False for i in range(n-1): for j in range(0, n-i-1): if arr[j] > arr[j+ 1]: swapped = True arr[j], arr[j+ 1] = arr[j+1], arr[j] if not swapped: return A. O(1) B. O(n log n) C. O(n) D. O(n²)
Given the hash function h(k) = k mod 12, answer the following question on hashing a) Insert the following keys into the
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am