Question: 2 . Consider the following algorithm and answer questions 1 f below. Just need e and f Algorithm A 1 Input: An array of n
Consider the following algorithm and answer questions f below.
Just need e and f
Algorithm A
Input: An array of n real numbers labelled A to An
Set minval to A
Set maxval to A
For i to n
If Ai minval
Set minval to Ai
If Ai maxval
Set maxval to Ai
Return maxval minval
a What does this algorithm compute?
b What is the basic operation?
c How many times is the basic operation executed?
d What is the efficiency class of this algorithm?
e If the list is sorted, is there a more efficient algorithm?
f If the list is not sorted, would sorting it as part of the algorithm be a more efficient algorithm?
Just need to answer e and f
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
