Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the following algorithm. ALGORITHM: Mystery ( A [ 0 . . n - 1 ] , B [ 0 . . n - 1
Consider the following algorithm.
ALGORITHM: MysteryAn Bnn
Input: Two samesized arrays An Bn of n real numbers, size of A B
a An
b Bn
for i n downto do
if Ai a then
a Ai
if Bib then
b Bi
return ba
a What does this algorithm compute?
b Which of the following statements about the output are true and which are false? Explain your answers by providing an argument for true statements and a counter example for false statements.
i It will be equal to a value in one of the arrays.
ii It can be negative.
iii. It will be between and n
c What is its basic operation?
d Show and simplify a summation for the number of times the basic operation is executed.
e What is the Theta timeefficiency class of this algorithm? Prove your result.
f Suggest an improvement, or a better algorithm altogether, and indicate its efficiency class, or make a convincing argument that no improvement is possible.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started