1 Fill in the blank in the following hash function: int HashMap::HashFunction(int k, int mapSize){ int h = 0; int tmp = k; while (tmp > 0) { h += tmp % 10; tmp = tmp/10; //here return h; } A (S) tmp +=1; B (H) h %= mapSize; C (R) if (h > 0) D (T) map[h++] = k; E (A) other

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
i need the answer quickly
Hash Maps:
1 Fill in the blank in the following hash function:
int HashMap::HashFunction(int k, int mapSize){
int h = 0;
int tmp = k;
while (tmp > 0) {
h += tmp % 10;
tmp = tmp/10;
}
//here
return h;
}
A (S) tmp +=1;
B (H) h %= mapSize;
C (R) if (h > 0)
D (T) map(h++] = k;
E (A) other
2. Assume you have a perfect hash function such that there are NEVER any collisions (woah! Amazing!). Fill in the blank, below,
in the findKey method that (solely) finds a particular key (a string, k) in the hashMap:
int findkey(string k, int mapSize) {
}
A (H) if (map[k] == key) return k;
B (U) for (int i = 0; i < mapSize; i++) { if (map[i]->key = k) return i; }
C (0) return map[k]%mapSize;
D (E) return hashFunk (k);
E (Y) other
3. Assume you've got a hashMap of size 10. Use the HashFunction, in 1, and linear probing to place the following keys into the
hashMap: 32,21,41,53,60,14
A (R)
1
2
3
5
6
7
8
9
21
32
41
60
53
14
в (L)
6
8
9
41
14
21
32
60
53
C (E)
1
2
3
4
5
6
7
8
53
14
41
60
21
32
D (I)
1
4
5
6
7
8
41
21
60
53
14
32
E (D) Other
Transcribed Image Text:Hash Maps: 1 Fill in the blank in the following hash function: int HashMap::HashFunction(int k, int mapSize){ int h = 0; int tmp = k; while (tmp > 0) { h += tmp % 10; tmp = tmp/10; } //here return h; } A (S) tmp +=1; B (H) h %= mapSize; C (R) if (h > 0) D (T) map(h++] = k; E (A) other 2. Assume you have a perfect hash function such that there are NEVER any collisions (woah! Amazing!). Fill in the blank, below, in the findKey method that (solely) finds a particular key (a string, k) in the hashMap: int findkey(string k, int mapSize) { } A (H) if (map[k] == key) return k; B (U) for (int i = 0; i < mapSize; i++) { if (map[i]->key = k) return i; } C (0) return map[k]%mapSize; D (E) return hashFunk (k); E (Y) other 3. Assume you've got a hashMap of size 10. Use the HashFunction, in 1, and linear probing to place the following keys into the hashMap: 32,21,41,53,60,14 A (R) 1 2 3 5 6 7 8 9 21 32 41 60 53 14 в (L) 6 8 9 41 14 21 32 60 53 C (E) 1 2 3 4 5 6 7 8 53 14 41 60 21 32 D (I) 1 4 5 6 7 8 41 21 60 53 14 32 E (D) Other
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY