Question: Consider the following problem: Given an array A of size n of integers, we want to count the number of occurrences of duplicates in A.

 Consider the following problem: Given an array A of size n

Consider the following problem: Given an array A of size n of integers, we want to count the number of occurrences of duplicates in A. For example, [7, 2, 8, 9,4,5,6, 1, 3, 8, 8, 4] (1) should tell the user the following information Element Occurrences 1 1 2 1 3 1 2 4 1 1 5 6 7 8 9 1 3 1 (a) Write an algorithm (in pseudocode) which solves this problem USING A HASH TABLE. (Do NOT use sorting.) Your algorithm is allowed to use any of the Hash Table operations in the notes. The inputs to your algorithm are an array All and the size n of the array. The algorithm should report the number of duplicates and (if you choose) return a data structure containing the information. (b) Assume your hash table has size at least 2n. Analyze the EXPECTED asymptotic running time of your algorithm on an array. Justify your running time analysis, including mentioning any assumptions you make to simplify your analysis. (c) Assume your hash table has size at least 2n. Analyze the WORST CASE running time of your algorithm on an array. Justify your running time analysis. Note: The worst case time for insertion/find in a hash table is different than the expected case time. The difference between the worst case and expected times of insertion/find in the hash table will affect the worst case and expected times of your algorithm

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!