1. Engineering
  2. Computer Science
  3. consider the element distinctness problem given an array a storing...

Question: consider the element distinctness problem given an array a storing...

Question details

Consider the element distinctness problem: Given an array A storing n inte- gers, determine whether all the elements in the array are distinct or not. That is, if all the elements in A are unique, return true; return false if there is at least one duplicate element in A. Below four different problem instances are provided; elements bolded are duplicate elements. 0 1 234 5 6 1231 234 false 0 1 2 3 4 5 0 1 2 3 true 0 1 23 4 5 6 7 1098 6 4321 true 412268 false Design an algorithm that solves the element distinctness problem a) [4 marks] Write pseudocode for the algorithm b) Prove your algorithm is correct, do this by proving the two following parts: i) [1 marks] Show that the algorithm terminates in finite time ii) [2 marks Show that the algorithm always produces correct output. c) 1 mark Explain what the worst case for the algorithm is d) [3 marks] Perform worst-case analysis to compute the time complexity of the algorithm You must give the order of your complexity function using Big-Oh notation, and you must explain how you computed the time complexity.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution