Question: EXERCISE 12.3.4: Worst-case time complexity -finding a target product of two numbers. FindProduct Input a1, a2 ,n n, the length of the sequence. prod, a

EXERCISE 12.3.4: Worst-case time complexity -finding a target product of two numbers. FindProduct Input a1, a2 ,n n, the length of the sequence. prod, a target product. Output: "Yes" if there are two numbers in the sequence whose product equals the input 'prod. Otherwise, 'No For i = 1 ton For j = i+1 to n If (a a, prod), Return( 'Yes') End-for End-for Return( "No) (a) Characterize the input that will cause the 'If statement in the inner loop to execute the most number of times. (b) Give an asymptotic lower bound for the running time of the algorithm based on your answer to the previous question. c) Was it important to use the worst-case input for the lower bound? That is, would any input of a given length have resulted in the same asymptotic lower bound? algorithm
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
