ma'am, how it can be O(1).

Suppose, there are 13 elements in array A like :-

A[0] = -15

A[1] = -13

A[2] = -11

A[3] = -8

A[4] = -7

A[5]= -3

mid1= A[6]= -2

A[7] = 0

A[8] = 2

mid2=A[9] = 7

A[10]= 9

mid3 = A[11]= 11

A[12]= 55

Since, array is sorted. So, 1st think about binary search. suppose mid means middle. Now, consider cases like :-

1) If A[mid] > mid then possibility of A[i] = i will be in the previous half from A[mid].

2) if A[mid] < mid then possibility of A[i] =i will be in next half from A[mid].

3) if A[mid] = mid then you don't have to do anything because your objective is already completed.

Now, if you apply it in above example then first we check middle element i.e. A[mid1] = -- 2 and mid1 is 6. so here, - 2 < 6..so apply case 2..then you will go in next half. Like this you can find A[i] =i if it exists.

Suppose, there are 13 elements in array A like :-

A[0] = -15

A[1] = -13

A[2] = -11

A[3] = -8

A[4] = -7

A[5]= -3

mid1= A[6]= -2

A[7] = 0

A[8] = 2

mid2=A[9] = 7

A[10]= 9

mid3 = A[11]= 11

A[12]= 55

Since, array is sorted. So, 1st think about binary search. suppose mid means middle. Now, consider cases like :-

1) If A[mid] > mid then possibility of A[i] = i will be in the previous half from A[mid].

2) if A[mid] < mid then possibility of A[i] =i will be in next half from A[mid].

3) if A[mid] = mid then you don't have to do anything because your objective is already completed.

Now, if you apply it in above example then first we check middle element i.e. A[mid1] = -- 2 and mid1 is 6. so here, - 2 < 6..so apply case 2..then you will go in next half. Like this you can find A[i] =i if it exists.