Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started