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(n2). 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 algorithm to count the number of duplicates again. Analyze the time complexity of your algorithm in the worst-case (ignore the time complexity 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 O(g(n)).
f1(n) = n2.5
f2(n) = sqrt(2n)
f3(n) = n10
f4(n) = 10n
f5(n) = 100n
f6(n) = 2n
f7(n) = n log n
f8(n) = n2 log n
f9(n) = 2n + 100
f10(n) = nn
f11(n) = n!
(b) Prove each case of f(n) = O(g(n)) in your arrangement above, by providing enough jusitification.
4. Assume you have functions f and g such that f(n) is O(g(n)). For each of the following statements, decide whether you think it is true or false and give a proof or counter example.
a) f(n)2 is O(g(n)2)
b) 2f(n) is O(2g(n))