Question
Algorithm Secret(A[0..n - 1])
//Input: An array A[0..n - 1] of n real numbers
minval ← A[0]; maxval ← A[0]
for i ← 1 to n - 1 do
if A[i] < minval
minval ← A[i]
if A[i] > maxval
maxval ← A[i]
return maxval - minval
a. What does this algorithm calculate?
b. What is its essential operation?
c. How many times is essential operation executed?
d. What is the effectiveness class of this algorithm?
e. propose a development or a better algorithm altogether and indicate its effectiveness class. If you cannot do it, try to prove that, in fact, it cannot be completed.