Question: Analysis of Algorithms 1. Write a program in either C++ or Java that counts the number of duplicates in a list of integer numbers. Your

Analysis of Algorithms

Analysis of Algorithms 1. Write a program in either C++ or Java

that counts the number of duplicates in a list of integer numbers.

1. Write a program in either C++ or Java that counts the number of duplicates in a list of integer numbers. Your program receives a list of n numbers and outputs the total number of duplicates. Your algorithm should be of order of O(na). in the worst-case. Analyze your algorithm in the worst-case. 2. Assume you have a sorting algorithm that you can use as a black box. Use the sorting algorithm to sort the input list. Now write an al- gorithm to count the number of duplicates again. Analyze the time complexity of your algorithm in the worst-case (ignore the time com- plexity of sorting). Could you improve the worst-case time complexity of your algorithm compared to the previous question? 3. (a) Take the following list of functions and arrange them in ascending order of growth rate. That is, if function g(n) immediately follows function f(n) in your list, then it should be the case that f(n) is (g(n)). fi(n) = n2.5 f(n) = 2n f(n) = n10 f(n) = 100 fs(n) = 1001 fon) = 2n f(n) = nlog n f(n) = n2 logn f(n) = 2n + 100 f10(n) = n fii(n) = n! (b) Prove each case of f(n)= (g(n)) in your arrangement above, by providing enough justification. 4. Assume you have functions f and g such that f(n) is (g(n)). For each of the following statements, decide whether you think it is true or false and give a proof or counterexample. a) f(n)2 is (g(n)) b) 2f(n) is O(29(n))

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!