Question: Given pseudocode, indicate basic operation and efficiency class ALGORITHM RevCount (A[0.. n - 1])//Input: array of integers from 1 to n in arbitrary order//Output: +1

Given pseudocode, indicate basic operation and efficiency class ALGORITHM RevCount (A[0.. n - 1])//Input: array of integers from 1 to n in arbitrary order//Output: +1 if there are even number of inversions; -1 otherwise s leftarrow 1 for i leftarrow 0 to n - 2 do for j leftarrow i + 1 to n - 1 do if A[i] > A[j] s leftarrow -s return s ALGORITHM Range (A[0..n-1], l, r)//Input: array of n real numbers in arbitrary order//Output: the smallest and the largest elements of the array if r - l max 2) max 2 = max 1 return (min 2, max 2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
