Answer to Question #127859 in C++ for yuxuan l i

Question #127859
Identify and describe the worst-case input and best case input

i←0
while i < n−2do
if A[i]A[i+1]> A[i+ 2] then
returning i
i←i+ 1
return−1
1
Expert's answer
2020-07-30T10:26:15-0400

From the above code,

i←0

while i < n−2do

if A[i]A[i+1]> A[i+ 2] then

returning i

i←i+ 1

return−1

For the best case- for all the value of n which is less than or equal to 2, it will show the best case input.

For the worst case input, if the value of n which will be greater than 2, and value of n will be greater then the termination of loop will go longer, so in that case it will show worst case input.



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS