Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

Uses effective delegation to develop others.

Answered: 1 week ago