Question: 4. (20 marks + 10 bonus marks) Given an array A of n elements that are integers from 0 to n-1, with any of these

 4. (20 marks + 10 bonus marks) Given an array A

4. (20 marks + 10 bonus marks) Given an array A of n elements that are integers from 0 to n-1, with any of these numbers appearing any number of times. 2 2 (a) (10 marks) Design an algorithm that finds the repeating numbers in A. For example, let n be 7 and array A be 1, 2, 3, 1, 3, 6, 6, the answer should be 1, 3 and 6. Give the pseudo code description of your algorithm and analyze its time complexity. (b) (10 marks) Implement your algorithm using Java. Your program takes any se- quence of numbers as the input, outputs the repeating number(s). (c) (bonus: 10 marks) Design an efficient algorithm for this task with time complexity O(n) and space complexity O(1)

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!