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

2. Consider the following algorithm and answer questions 1 f below.
Just need e and f
Algorithm A1
Input: An array of n real numbers labelled A[0] to A[n 1]
Set minval to A[0]
Set maxval to A[0]
For i =1 to n
If A[i]< minval
Set minval to A[i]
If A[i]> maxval
Set maxval to A[i]
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 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!