Question: Take a look at the following pseudocode. Input: An array A [ 1 . . n ] of n integers Output: [ an appropriate description

Take a look at the following pseudocode.
Input: An array A[1..n] of n integers
Output: [an appropriate description of the output]
Mystery1(A[1..n])
returnValue larr0
for ilarr1 to n-1 do
for jlarri+1 to n do
if |A[i]-A[j]|> returnValue then
returnValue larr|A[i]-A[j]|
return returnValue
a. Provide an English description of the output of the algorithm. Don't just say what
each line of the code does. Instead, describe what property the output has. For example,
for the maximum algorithm mentioned in class, an appropriate description of the output
would be "The maximum element in array ..n." An inappropriate description of
the output would be "Compares each element to the maximum element seen so far and
then updates the current maximum. Return the current maximum at the end."
b. Identify the line (or lines) in the pseudocode gets executed the most. You may assume
that n is a large number.
c. Write a mathematical expression (probably involving summations) for the number of
times that the line from part b gets executed (as a function of n), and then simplify it into
closed form (no summations left in the simplified expression). Show all of your work.
 Take a look at the following pseudocode. Input: An array A[1..n]

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!