Given an integer array [A], efficiently find a descending sorted triplet such that: A[i]> A[i] > A[k] and 0 <=i

icon
Related questions
Question
100%

need solve it

Given an integer array [A], efficiently find a descending sorted triplet such that:
A[i]> A[i]> A[k] and 0 <=i<j <k <n, where n is the array size.
For example,
Input: A[] = {9, 1, 6, 7, 3, 4, 5)
Output: Any one of the following triplets:
(9, 7,5)
(9, 7, 4)
(9, 7, 3)
(9, 6, 5)
(9, 6, 4)
(9, 6, 3)
a) Design a brute-force algorithm to solve this problem
complexity of your solution
b) Design a more efficient algorithm to do the same task with less complexity
and analyse the complexity of your solution.
c) Develop a python code to implement your efficient algorithm.
depend on the correctness of the code, indentation, comments, test-case]
d) Prepare a brief report (250 words) comparing the two algorithms
and analyse the
Transcribed Image Text:Given an integer array [A], efficiently find a descending sorted triplet such that: A[i]> A[i]> A[k] and 0 <=i<j <k <n, where n is the array size. For example, Input: A[] = {9, 1, 6, 7, 3, 4, 5) Output: Any one of the following triplets: (9, 7,5) (9, 7, 4) (9, 7, 3) (9, 6, 5) (9, 6, 4) (9, 6, 3) a) Design a brute-force algorithm to solve this problem complexity of your solution b) Design a more efficient algorithm to do the same task with less complexity and analyse the complexity of your solution. c) Develop a python code to implement your efficient algorithm. depend on the correctness of the code, indentation, comments, test-case] d) Prepare a brief report (250 words) comparing the two algorithms and analyse the
Expert Solution
steps

Step by step

Solved in 5 steps with 1 images

Blurred answer