Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Course: algorithms of data structure based on the question of this answer https://www.chegg.com/homework-help/questions-and-answers/course-complexity-theory-data-structures-please-answer-shown-questions-explanation-one--ex-q107647523 please make sure that the answer is correct, I will vote up

Course: algorithms of data structure

based on the question of this answer https://www.chegg.com/homework-help/questions-and-answers/course-complexity-theory-data-structures-please-answer-shown-questions-explanation-one--ex-q107647523

please make sure that the answer is correct, I will vote up and write a good review for sure if the answer is correct. needed urgently Thanks

image text in transcribed
For the system proposed in the Question 2 above, suppose the goal is to find the mark of a student using 9. first name (more than one student might be retumed if more than one student has the same name) b. last name (similarly, more than one student might be returned) c. both first name and last name For this, both Kimo and Shadi suggested using hashtables as the underlying data structure. However, both proposed two different approsches. Kimo suggested to use two hashtables of lists. The first hashtable is called FirstHash. Firsthash uses the first name as the key; while the value is the list of students that has the same first name. Similarly, the second hashtable is called LastHash and uses last name as the key: while the value is the list of students that has the same last name. Finding the list of students with the same first name (or the same last name) is now a simple lookup from the a hashtable. To find the mark of a specific student, with specific first name and last name, Kimo suggested the following algorithm (the algorithm computes the intersection of the two lists produced by both tables): Input: firstName and lastName Output result 1. Result t null 2. LastList FirstHash.get( firstName ) 3. For every item it in LastList, a. If i1. lastName == lastName then result i1 Shadi suggested to use a third hashtable DoubleHash. DoubleHash uses the first name as the key; while value is a hashtable (instead of a list). The algorithm to find the mark by both first and last names then becomes: Input: firstName and lastName 1. LastHash DoubleHash.get( firstName) 2. Result t Lasthash.get( lastName) Answer the following questions, assuming it takes O(1) to compare two strings and check if they are equal 1. What is the time complexity of the algorithm proposed by Kimo? Explain your answer 2. What is the time complexity of the algorithm proposed by Shadi? Explain your answer 3. Is there any benefitladvantage of Kimo's approach (compared to Shadi's approach)? 4. What if we use a hashtable where the key is the concatenation of both first and last names? How does the time complexity of finding a mark using both first and last name compares to the above two methods? Explain your

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions