Question: Question 1: For the algorithm on the right: 1. What is its basic operation? 2. What is the efficiency class of this algorithm? Solve a
Question 1: For the algorithm on the right:
1. What is its basic operation?
2. What is the efficiency class of this algorithm? Solve a summation to support your answer.
3. Are the best, average, and worst case time efficiencies the same? Justify your reasoning.
Algorithm 1: Range(A[0...n 1])
1: Input: An array A[0...n 1] of n real numbers
2: minval = A[0];
3: maxval = A[0];
4: for i = 1 to n 1 do
5: if A[i] < minval then
6: minval = A[i];
7: if A[i] > maxval then
8: maxval = A[i];
9: end
10: return maxval - minval;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
