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, 12, 17, 10 
The maximum, minimum, and average chain lengths in the hash table, respectively, are
  • 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 ...
View all questions of this test
Most Upvoted Answer
Consider a hash table with 9 slots. The hash function is h(k) = k mod ...
Explanation:

The given hash table has 9 slots and the hash function is defined as h(k) = k mod 9. In this hash function, the key is divided by 9 and the remainder is used as the hash value.

Insertion of keys:

The following 9 keys are inserted in the given order: 5, 28, 19, 15, 20, 33, 12, 17, 10.

Hashing of keys:

To find the hash value of each key, we apply the hash function h(k) = k mod 9.

- Key 5: h(5) = 5 mod 9 = 5
- Key 28: h(28) = 28 mod 9 = 1
- Key 19: h(19) = 19 mod 9 = 1 (Collision with key 28, chaining)
- Key 15: h(15) = 15 mod 9 = 6
- Key 20: h(20) = 20 mod 9 = 2
- Key 33: h(33) = 33 mod 9 = 6 (Collision with key 15, chaining)
- Key 12: h(12) = 12 mod 9 = 3
- Key 17: h(17) = 17 mod 9 = 8
- Key 10: h(10) = 10 mod 9 = 1 (Collision with keys 28 and 19, chaining)

Final hash table:

The final hash table with chaining is as follows:

Slot 0: Empty
Slot 1: 5 -> 28 -> 19 -> 10
Slot 2: 20
Slot 3: 12
Slot 4: Empty
Slot 5: Empty
Slot 6: 15 -> 33
Slot 7: Empty
Slot 8: 17

Maximum chain length:

The maximum chain length in the hash table is 3, which occurs in slot 1.

Minimum chain length:

The minimum chain length in the hash table is 0, which occurs in slots 0, 4, 5, and 7.

Average chain length:

To find the average chain length, we sum up the lengths of all non-empty chains and divide it by the number of non-empty slots.

Average chain length = (length of chain in slot 1 + length of chain in slot 2 + length of chain in slot 3 + length of chain in slot 6 + length of chain in slot 8) / 5
Average chain length = (4 + 1 + 1 + 2 + 1) / 5
Average chain length = 9 / 5
Average chain length = 1.8

Therefore, the maximum, minimum, and average chain lengths in the hash table are 3, 0, and 1, respectively.
Explore Courses for Computer Science Engineering (CSE) exam

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 are resolved by chaining. The following 9 keys are inserted in the order:5, 28, 19, 15, 20, 33, 12, 17, 10The maximum, minimum, and average chain lengths in the hash table, respectively, area)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 are resolved by chaining. The following 9 keys are inserted in the order:5, 28, 19, 15, 20, 33, 12, 17, 10The maximum, minimum, and average chain lengths in the hash table, respectively, area)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 are resolved by chaining. The following 9 keys are inserted in the order:5, 28, 19, 15, 20, 33, 12, 17, 10The maximum, minimum, and average chain lengths in the hash table, respectively, area)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 are resolved by chaining. The following 9 keys are inserted in the order:5, 28, 19, 15, 20, 33, 12, 17, 10The maximum, minimum, and average chain lengths in the hash table, respectively, area)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 are resolved by chaining. The following 9 keys are inserted in the order:5, 28, 19, 15, 20, 33, 12, 17, 10The maximum, minimum, and average chain lengths in the hash table, respectively, area)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 are resolved by chaining. The following 9 keys are inserted in the order:5, 28, 19, 15, 20, 33, 12, 17, 10The maximum, minimum, and average chain lengths in the hash table, respectively, area)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 are resolved by chaining. The following 9 keys are inserted in the order:5, 28, 19, 15, 20, 33, 12, 17, 10The maximum, minimum, and average chain lengths in the hash table, respectively, area)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 are resolved by chaining. The following 9 keys are inserted in the order:5, 28, 19, 15, 20, 33, 12, 17, 10The maximum, minimum, and average chain lengths in the hash table, respectively, area)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 are resolved by chaining. The following 9 keys are inserted in the order:5, 28, 19, 15, 20, 33, 12, 17, 10The maximum, minimum, and average chain lengths in the hash table, respectively, area)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 are resolved by chaining. The following 9 keys are inserted in the order:5, 28, 19, 15, 20, 33, 12, 17, 10The maximum, minimum, and average chain lengths in the hash table, respectively, area)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