Why "Hash Table" rather than "2D Array" here?

HI All,

This is the task during the “Data Structure” course.

Scenario C: Now every person who RSVPs for the wedding indicates which meal they want. You have to keep track of both the person and the meal order. You need to be able to find out what meal a particular person ordered quickly, so the waiters don’t delay too long when it comes time to eat.

The answer is: scenario_C_data_structure = “hash table”

Why this can not be “2D Array”? Also I thought hash table will take a lot of empty space in case of collision so is it still the best answer?

1 Like

Searching will be faster in a hash table when compared to 2D array and Moreover here the problem statement is " You need to be able to find out what meal a particular person ordered quickly, so the waiters don’t delay too long when it comes time to eat"

I hope you find your answer now

1 Like