Question: 5. Consider the following problem: Given an array of n integers, are there any duplicate integers in the array? (a) Write an algorithm (in pseudocode)
5. Consider the following problem: Given an array of n integers, are there any duplicate integers in the array? (a) Write an algorithm (in pseudocode) which solves this problem USING A HASH TABLE. (Do NOT use sorting.) Your algorithm should use the hash table operations, Initialize, Insert, Retrieve and Member. Input to your algorithm is an array Al and the number of integers n in the array. The algorithm returns true if there are any duplicate numbers in the array and false otherwise. (b) Assume your hash table has size at least 2n. Analyze the EXPECTED asymptotic running time of your algorithm on an array with no duplicate numbers. Justify your running time analysis. (c) Assume your hash table has size at least 2n. Analyze the WORST CASE running time of your algorithm on an array with no duplicate numbers. Justify your running time analysis. (Note that 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
Get step-by-step solutions from verified subject matter experts
