You seem to know what you are doing.
The theory behind a binary search is that you are looking within an ascending sorted list and you search for it by cutting the list in half to check to see if it is the value you are looking for...if it's not you check to see if the if the value you are looking for is higher or lower than what you landed at and cut that half of the list in half and do it again.
A basic binary search algorithm is pretty much as follows:
 Set
LeftPosition
to 0 and RightPosition
to the number of items int the array − 1.  If
LeftPosition
> RightPosition
, the search terminates as unsuccessful because your list is empty or you have searched through the whole array.  Set
MidPoint
(the position of the middle element) to the floor (the largest previous integer) of (LeftPostition
+ RightPostion
) / 2. If
ValueAtTheMidPointPostitionInTheArray
< WhatYouAreLookingFor
, set LeftPostion
to MidPoint
+ 1 and go to step 2.  If
ValueAtTheMidPointPostitionInTheArray
> WhatYouAreLookingFor
, set RightPosition
to MidPoint
− 1 and go to step 2.
 Now
ValueAtTheMidPointPostitionInTheArray
= WhatYouAreLookingFor
, the search is done; return MidPoint
.
The BigO notation for the worst case (when you don't find anything) is O(log n) because you are constantly dividing the list in half and so the operations required to complete the search decrease with each iteration.
You should step through the algorithm and draw out your trees to figure out how many iterations it takes to get to each elementposition that you are looking for.
Your first search tree(search for index 499) looks something like:

(1000)

/ \

(0500) (501999)

/ \

(0250) (251500)

/ \

(251375) (376500)

/ \

(376438) (439500)

/ \

(438469) (470500)

/ \

(469485) (486500)

/ \

(485493) (494500)

/ \

(493497) (498500)

/ \

(499) (500)



(found)
