Question

In: Computer Science

Consider a hash table T with m=10 slots that uses open addressing with linear probing and...

Consider a hash table T with m=10 slots that uses open addressing with linear probing and the hash function h(k,i) = ((k mod m) + i) mod m, where i = 0,1,..., m-1 is the probe number.

Show T after inserting keys <867,755,535,296,866,135,669,445,524>.

Solutions

Expert Solution

Solution:

Given,

=>Hash table size(m) = 10

=>Linear probing is used for collision resolution

=>Hash function: h(k) = (kmodm + i) mod m where i = 0, 1 ....m-1

=>Keys = 867, 755, 535, 296, 866, 135, 669, 445, 524

Explanation:

Inerting keys:

Insert 487:

=>487 mod 10 = 7

Insert 755:

=>755 mod 10 = 5

Insert 535:

=>535 mod 10 = 5(collision)

=>(5 + 1) mod 10 = 6

Insert 296:

=>296 mod 10 = 6(collision)

=>(6 + 1) mod 10 = 7(collision)

=>(6 + 2) mod 10 = 8

Insert 866:

=>866 mod 10 = 6(collision)

=>(6 + 1) mod 10 = 7(collision)

=>(6 + 2) mod 10 = 8(collision)

=>(6 + 3) mod 10 = 9

Insert 135:

=>135 mod 10 = 5(collision)

=>(5 + 1) mod 10 = 6(collision)

=>(6 + 1) mod 10 = 7(collision)

=>(6 + 2) mod 10 = 8(collision)

=>(6 + 3) mod 10 = 9(collision)

=>(6 + 4) mod 10 = 0

Insert 669:

=>669 mod 10 = 9(collision)

=>(9 + 1) mod 10 = 0(collision)

=>(9 + 2) mod 10 = 1

Insert 445:

=>445 mod 10 = 5(collision)

=>(5 + 1) mod 10 = 6(collision)

=>(6 + 1) mod 10 = 7(collision)

=>(6 + 2) mod 10 = 8(collision)

=>(6 + 3) mod 10 = 9(collision)

=>(6 + 4) mod 10 = 0(collision)

=>(6 + 5) mod 10 = 1(collision)

=>(6 + 6) mod 10 = 2

Insert 524:

=>524 mod 10 = 4

Final hash table:

135 669 445 524 755 535 487 296 866

    0           1           2        3     4          5             6         7           8              9

I have explained each and every part with the help of statements attached to the answer above.


Related Solutions

Write an algorithm to delete an element from a hash table that uses linear probing as...
Write an algorithm to delete an element from a hash table that uses linear probing as its clash resolution strategy. Analyze your algorithm and show the results using order notation?
A hash table works as follows. We allocate a table of m slots. All the items...
A hash table works as follows. We allocate a table of m slots. All the items we intend to store in the table belong to a large set U of items. We adopt a function f: U ->{0,1...m-1) which maps an item to a slot. Suppose we seek to store n items from U in a table of m slots. (a) Suppose f maps every item in U with equal probability to one of the m slots. What is the...
Consider inserting n distinct keys into a hash table with m buckets, where collisions are resolved...
Consider inserting n distinct keys into a hash table with m buckets, where collisions are resolved by chaining and simple uniform hashing applies. 1. What is the probability that none of the n keys hashed to a particular bucket? 2. What is the expected number of empty buckets? 3. What is the expected number of collisions?
1.) Consider inserting values 15, 22 and 29 in the order given into a hash table...
1.) Consider inserting values 15, 22 and 29 in the order given into a hash table of size 7 with hash function h(x) = x mod 7. What will be the locations be the respective locations for 15, 22 and 29 in the hash table if quadratic probing is used to resolve colisions? a. 1, 2, 4 b. 1, 2, 3 c. 1, 2, 0 d. 1, 1, 1 2.) Consider the following sequences of addqs and removeqs, what order...
Consider inserting values 15, 22 and 29 in the order given intoa hash table of...
Consider inserting values 15, 22 and 29 in the order given into a hash table of size 7 with hash function h(x) = x mod 7. What will be the locations be the respective locations for 15, 22 and 29 in the hash table if quadratic probing is used to resolve colisions?a.1, 2, 4b.1, 2, 3c.1, 2, 0d.1, 1, 1
Consider the linear transformation T: R2x2 -> R2x2 defined by T(A) = AT - A. Determine...
Consider the linear transformation T: R2x2 -> R2x2 defined by T(A) = AT - A. Determine the eigenvalues of this linear transformation and their algebraic and geometric multiplicities.
. Let T : R n → R m be a linear transformation and A the...
. Let T : R n → R m be a linear transformation and A the standard matrix of T. (a) Let BN = {~v1, . . . , ~vr} be a basis for ker(T) (i.e. Null(A)). We extend BN to a basis for R n and denote it by B = {~v1, . . . , ~vr, ~ur+1, . . . , ~un}. Show the set BR = {T( r~u +1), . . . , T( ~un)} is a...
void phase05(){ int n = atoi(next_input()); int m = atoi(next_input()); int t = (hash % 30)...
void phase05(){ int n = atoi(next_input()); int m = atoi(next_input()); int t = (hash % 30) + 21; int s = 0; while(n>1){ if(n & 1){ n = (n<<2) - n + 1; } else { n = n >> 1; } if(s == t && m == t){ return; } s++; } failure("Seems you forgatz the essence of Collatz"); } Hash value: 2002296385 what input values should n, m have in order for the function phase05 to work?
Data Structures: Hashing Exercise: 1. a) Given an empty “separate chaining hash table” of size 10,...
Data Structures: Hashing Exercise: 1. a) Given an empty “separate chaining hash table” of size 10, with hash function                        Location = Number modulus 10 Show the hash table after inserting the following numbers: 21, 18, 27 , 31 , 48, 51 , 37, 98, 17 b) What table size would be better? 11? 12? 20? 2. We want to hash name strings into a chaining hash table of size 10, how would you divide the alphabet into 10 groups?...
Consider the linear transformation T : P1 → R^3 given by T(ax + b) = [a+b...
Consider the linear transformation T : P1 → R^3 given by T(ax + b) = [a+b a−b 2a] a) find the null space of T and a basis for it (b) Is T one-to-one? Explain (c) Determine if w = [−1 4 −6] is in the range of T (d) Find a basis for the range of T and its dimension (e) Is T onto? Explain
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT