20.8k views
3 votes
Can you help me in this question

Can you help me in this question-example-1

1 Answer

2 votes

Answer:

6 2 and 0

Step-by-step explanation:

This algorithm doesn't work if the list is not ordered ascending.

In this example it is not, and indeed the item "1" is never found.

first cycle: first=0, last=12 so midpoint=6

second cycle: first=0, last=5 so midpoint=2

last cycle: first=0, last=1 so midpoint=0

then last is assigned -1 so the while statement is no longer true.

User Nikhlesh Bagdiya
by
4.4k points