Gate 2010
Duration: 3 min
This video lesson is available to enrolled students.
AI Summary
An AI-generated summary of this video lecture.
The video presents a solution to a GATE 2010 computer science problem involving hash tables. The problem specifies a hash table of length 10 using open addressing with linear probing and the hash function h(k) = k mod 10. The goal is to determine the insertion order of six keys given the final table state. The instructor begins by listing the provided options and analyzing the hash values for each key present in the table: 42, 23, 34, 52, 46, and 33. He calculates their initial positions: 42 and 52 map to index 2, 23 and 33 map to index 3, 34 maps to index 4, and 46 maps to index 6. He observes that 52 and 33 are displaced from their primary hash positions because indices 2 and 3 are occupied by 42 and 23 respectively. This observation is crucial for eliminating incorrect options.
Chapters
0:00 – 2:00 00:00-02:00
The instructor reads the problem statement and displays the hash table with values at indices 2, 3, 4, 5, 6, and 7. He writes down the hash function h(k) = k mod 10 and calculates the primary hash index for each key: 42->2, 23->3, 34->4, 52->2, 46->6, 33->3. He notes that 52 and 33 must have probed further because their target slots were occupied. He starts evaluating the options, specifically looking at the order of insertion to see if it results in the observed displacements. He marks option (A) as incorrect because inserting 52 before 23 would place 52 at index 3, contradicting the table.
2:00 – 2:51 02:00-02:51
The instructor focuses on verifying option (C): 46, 34, 42, 23, 52, 33. He simulates the insertion process step-by-step. First, 46 goes to index 6. Then 34 goes to index 4. Next, 42 goes to index 2. Then 23 goes to index 3. When 52 is inserted, it hashes to 2 (occupied by 42), probes 3 (occupied by 23), probes 4 (occupied by 34), and lands at index 5. Finally, 33 hashes to 3 (occupied by 23), probes 4, 5, 6 (occupied by 46), and lands at index 7. This sequence perfectly matches the final table configuration shown in the problem. He concludes that option (C) is the correct answer.
The lesson effectively teaches how to validate insertion sequences in hash tables with linear probing. By calculating initial hash positions and simulating the probing sequence for each candidate option, one can determine the valid order. The key takeaway is that displaced elements must find the first available slot after their primary hash index, skipping over previously inserted elements.