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))
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.