Question Details

Consider a hash table P[0,1,...,10] that is initially empty. The hash table is maintained using open addressing with linear probing. The hash function used is h(x) = (x + 7) (mod 11). Consider the following sequence of insertions performed on P: 1,13,22,15,11,24. Which of the following positions in the hash table is/are empty after these insertions are performed?

Options

A

0

B

10

C

2

D

1

Show Answer
Correct Answer
C 2

Solution :

The correct option is 2 (which corresponds to position/index 2 in the hash table).

Let us understand why this is correct by walking through the step-by-step insertion of the keys into the hash table of size 11 (indices 0 to 10), using open addressing with linear probing.
The given hash function is:

h ( x ) = ( x + 7 ) mod 11

Under linear probing, if a collision occurs at a slot i, we check subsequent slots sequentially in the order:
( i + 1 ) mod 11 , ( i + 2 ) mod 11 , and so on, until an empty slot is found.

Initially, the hash table is completely empty:
P = [empty, empty, empty, empty, empty, empty, empty, empty, empty, empty, empty]

Step 1: Insert key 1
Compute the hash value:

h ( 1 ) = ( 1 + 7 ) mod 11 = 8 mod 11 = 8

Slot 8 is empty, so we place 1 at index 8.
P[8] = 1

Step 2: Insert key 13
Compute the hash value:

h ( 13 ) = ( 13 + 7 ) mod 11 = 20 mod 11 = 9

Slot 9 is empty, so we place 13 at index 9.
P[9] = 13

Step 3: Insert key 22
Compute the hash value:

h ( 22 ) = ( 22 + 7 ) mod 11 = 29 mod 11 = 7

Slot 7 is empty, so we place 22 at index 7.
P[7] = 22

Step 4: Insert key 15
Compute the hash value:

h ( 15 ) = ( 15 + 7 ) mod 11 = 22 mod 11= 0

Slot 0 is empty, so we place 15 at index 0.
P[0] = 15

Step 5: Insert key 11
Compute the hash value:

h ( 11 ) = ( 11 + 7 ) mod 11 = 18 mod 11 = 7

Let's resolve the collision for key 11 using linear probing:
- Attempt 1: Slot 7 is occupied (contains 22). We check the next slot (7 + 1 = 8).
- Attempt 2: Slot 8 is occupied (contains 1). We check the next slot (8 + 1 = 9).
- Attempt 3: Slot 9 is occupied (contains 13). We check the next slot (9 + 1 = 10).
- Attempt 4: Slot 10 is empty, so we place 11 at index 10.
P[10] = 11

Step 6: Insert key 24
Compute the hash value:

h ( 24 ) = ( 24 + 7 ) mod 11 = 31 mod 11 = 9

Let's resolve the collision for key 24 using linear probing:
- Attempt 1: Slot 9 is occupied (contains 13). We check the next slot (9 + 1 = 10).
- Attempt 2: Slot 10 is occupied (contains 11). We check the next slot (10 + 1 = 11 mod 11 = 0).
- Attempt 3: Slot 0 is occupied (contains 15). We check the next slot (0 + 1 = 1).
- Attempt 4: Slot 1 is empty, so we place 24 at index 1.
P[1] = 24

Final State of the Hash Table:
- P[0] = 15
- P[1] = 24
- P[2] = empty
- P[3] = empty
- P[4] = empty
- P[5] = empty
- P[6] = empty
- P[7] = 22
- P[8] = 1
- P[9] = 13
- P[10] = 11

Comparing the state of the hash table with the given options (0, 10, 2, 1), we see that position 2 remains empty, whereas slots 0, 1, and 10 are occupied.

Transparent Access on Mindyard

Built for Learners & Educators Alike

Completely free for students. Educators & coaching institutes get 2 months free Pro trial to create tests.

FREE FOR STUDENTS

Practice & Learn Free for Students

Access unlimited practice questions, detailed step-by-step solutions, and exam study materials — completely free for students.

  • Unlimited mock tests & question bank practice
  • Full access to curated study library & formula notes
  • 100% free for students • No credit card required
2 MONTHS FREE TRIAL

Educators & Coaching Institutes

Create and conduct professional online assessments with AI question generation, tab proctoring, and comprehensive batch management.

  • AI question uploader & rapid test generator
  • Anti-cheating tab proctoring & performance reports
  • Full Pro access free for 60 days • No upfront commitment
Discover more resources

You may also like

Mock Tests

View All
  • GATE
  • beginner
  • 3 hours
  • computer science and information technology

Prepare effectively for GATE 2026 Computer Science & Information Technology (CS & IT) with this comprehensive Question Paper with Solutions. This resource includes detailed explanations, concept-wise solutions, previous year paper analysis, and exam-oriented practice to help aspirants strengthen core subjects like Data Structures, Algorithms, Operating Systems, DBMS, Computer Networks, Theory of Computation, Compiler Design, and more. Perfect for revision, self-assessment, and boosting your GATE 2026 preparation strategy.

  • GATE
  • intermediate
  • 3 hours
  • computer science and information technology

Prepare for GATE 2026 Electrical Engineering (EE) with high-quality study material, previous year question papers, mock tests, syllabus updates, exam pattern, and expert preparation strategies. Master core EE subjects including Power Systems, Control Systems, Electrical Machines, Circuit Theory, Signals & Systems, Power Electronics, and Measurements to secure a top rank in GATE 2026.

Ask AI Tutor
5 left
Q1 View Question & Options
AI Tutor is solving this question...
Reading question context & options...
Ask your own doubt or choose a quick prompt: