Question: Consider the pseudocode below Algorithm: bool sum( int aValue) // Determines the sum of items larger than aValue in a sorted list of n
Consider the pseudocode below Algorithm: bool sum( int aValue) // Determines the sum of items larger than aValue in a sorted list of n // items x[0], x[1],, x[n-1]. Stops when the sum is larger than 100. // Returns true if this sum is larger than 100; false otherwise. bool larger 100 = false; int sum= 0; for (int i=0; i aValue) { sum + x[i] larger100 = (sum> 100); } return larger100; a. Determine the input size and the key step. b. To analyse the time complexity, detrmine the best case, worst case, and average case. Justify your asnwer in details.
Step by Step Solution
3.47 Rating (150 Votes )
There are 3 Steps involved in it
a Input Size and Key Step The input size of the algorithm is determined by the size of the sorted list x Given that the list is indexed from x0 to xn1 ... View full answer
Get step-by-step solutions from verified subject matter experts
