Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider a hash table with 9 slots. The hash ... Start Learning for Free
Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions are
resolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33,
  • a)
    3, 0, and 1
  • b)
    3, 3, and 3
  • c)
    4, 0, and 1
  • d)
    3, 0, and 2
Correct answer is option 'A'. Can you explain this answer?
Verified Answer
Consider a hash table with 9 slots. The hash function is h(k) = k mod ...
Following are values of hash function for all keys

 5 --> 5
28 --> 1
19 --> 1  [Chained with 28]
15 --> 6
20 --> 2
33 --> 6  [Chained with 15]
12 --> 3
17 --> 8
10 --> 1 [Chained with 28 and 19]
The maximum chain length is 3. The keys 28, 19 and 10 go to same slot 1, and form a chain of length 3.
The minimum chain length 0, there are empty slots (0, 4 and 7).
Average chain length is (0 + 3 + 1 + 1 + 0 + 1 + 2 + 0 + 1)/9 = 1
View all questions of this test
Most Upvoted Answer
Consider a hash table with 9 slots. The hash function is h(k) = k mod ...
Hash Table with Chaining

A hash table is a data structure that allows for efficient access and retrieval of data based on a key. In this scenario, we have a hash table with 9 slots, and collisions are resolved by chaining.

Hash Function

The hash function used in this scenario is h(k) = k mod 9. This function takes a key, k, and returns the remainder when k is divided by 9. This ensures that the key is assigned to one of the 9 slots in the hash table.

Insertion of Keys

The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33, 3, 0, and 1. Let's see how each key is inserted into the hash table:

- Key 5: h(5) = 5 mod 9 = 5. Key 5 is inserted into slot 5.
- Key 28: h(28) = 28 mod 9 = 1. Key 28 is inserted into slot 1.
- Key 19: h(19) = 19 mod 9 = 1. Key 19 collides with key 28 in slot 1 and is added to the chain.
- Key 15: h(15) = 15 mod 9 = 6. Key 15 is inserted into slot 6.
- Key 20: h(20) = 20 mod 9 = 2. Key 20 is inserted into slot 2.
- Key 33: h(33) = 33 mod 9 = 6. Key 33 collides with key 15 in slot 6 and is added to the chain.
- Key 3: h(3) = 3 mod 9 = 3. Key 3 is inserted into slot 3.
- Key 0: h(0) = 0 mod 9 = 0. Key 0 is inserted into slot 0.
- Key 1: h(1) = 1 mod 9 = 1. Key 1 collides with keys 28 and 19 in slot 1 and is added to the chain.

Answer

The correct answer is option 'A' (3, 0, and 1). This is because keys 3, 0, and 1 are inserted into slots 3, 0, and 1 respectively, without any collisions.
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions areresolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33,a)3, 0, and 1b)3, 3, and 3c)4, 0, and 1d)3, 0, and 2Correct answer is option 'A'. Can you explain this answer?
Question Description
Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions areresolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33,a)3, 0, and 1b)3, 3, and 3c)4, 0, and 1d)3, 0, and 2Correct answer is option 'A'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions areresolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33,a)3, 0, and 1b)3, 3, and 3c)4, 0, and 1d)3, 0, and 2Correct answer is option 'A'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions areresolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33,a)3, 0, and 1b)3, 3, and 3c)4, 0, and 1d)3, 0, and 2Correct answer is option 'A'. Can you explain this answer?.
Solutions for Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions areresolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33,a)3, 0, and 1b)3, 3, and 3c)4, 0, and 1d)3, 0, and 2Correct answer is option 'A'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions areresolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33,a)3, 0, and 1b)3, 3, and 3c)4, 0, and 1d)3, 0, and 2Correct answer is option 'A'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions areresolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33,a)3, 0, and 1b)3, 3, and 3c)4, 0, and 1d)3, 0, and 2Correct answer is option 'A'. Can you explain this answer?, a detailed solution for Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions areresolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33,a)3, 0, and 1b)3, 3, and 3c)4, 0, and 1d)3, 0, and 2Correct answer is option 'A'. Can you explain this answer? has been provided alongside types of Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions areresolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33,a)3, 0, and 1b)3, 3, and 3c)4, 0, and 1d)3, 0, and 2Correct answer is option 'A'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions areresolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33,a)3, 0, and 1b)3, 3, and 3c)4, 0, and 1d)3, 0, and 2Correct answer is option 'A'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev