Question: 4. Let A be an array storing n integer values. The goal is to design an algorithm that returns true if every value stored in

4. Let A be an array storing n integer values. The goal is to design an algorithm that returns true if every value stored in A is different, and it returns false if there is at least one value that appears at least twice in A For example, for the following array A the algorithm must return true as all values are different; however for array B it must return false as the values 3 and 4 appear twice. 3617245 231443 (4 marks) Write pseudocode for an algorithm as described above. Prove that your algorithm is correct: (a) (1 mark) Show that the algorithm terminates (b) (2 marks) Show that the algorithm always produces the correct answer. (1 mark) Explain what the worst case for the algorithm is. (3 marks) Compute the time complexity of the algorithm in the worst case. You must give the order of the time complexity using "big-Oh" notation and you must explain how you computed the time complexity
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
