Question: Given an array of different integers, replace each element by its corresponding descending order in the array. The maximum array element has the order
Given an array of different integers, replace each element by its corresponding descending order in the array. The maximum array element has the order 1; the second maximum element has order 2, and so on... For example, Input: [10, 12, 17, 14, 8, 3, 22} Output: {5. 4. 2, 3, 6, 7, 1} a) Design a brute-force algorithm to solve this problem (4 marks), and analyse the complexity of your solution (2 marks) b) Design a more efficient algorithm to do the same task with less complexity (7 marks), and analyse the complexity of your solution. (3 marks) c) Develop a python code to implement your efficient algorithm. (10 marks) [The marks depend on the correctness of the code, indentation, comments, test-case] d) Prepare a brief report (250 words) comparing the two algorithms (4 marks)
Step by Step Solution
There are 3 Steps involved in it
Lets address each part of your question a Bruteforce algorithm Iterate through each element in the a... View full answer
Get step-by-step solutions from verified subject matter experts
