DATAMEX INSTITUTE OF COMPUTER TECHNOLOGY
101 P. GOMEZ STREET TACLOBAN CITY

DATA STRUCTURE

BINARY SEARCH

SUBITTED BY:
GROUP 6
MEMBERS
SOYOSA, JEROME A.
UYVICO, FRANCIS L.
LACATANGO, JULITA S
WENCESLAO, GERARDO JR
BSIT 1 BATCH 3
SUBMITTED TO:
PAUL ANTHONY SOLIS F.
INSTRUCTOR
DATE 15/12/2011

DEFINITION OF BINARY SEARCH
Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.

EXAMPLE OF BINARY SEARCH

The binary search is the standard method for searching
through a sorted array. It is
much more efficient than a linear search, where we pass
through the array elements in
turn until the target is found. It does require that the
elements be in order.
The binary search repeatedly divides the array in two, each
time restricting the search to
the half that should contain the target element.
In this example, we search for the integer 5 in the 10-
element array below:
2 : 5 : 6 : 8 : 10 : 12 : 15 : 18 : 20 : 21

Loop 1 - Look at whole array
Low index = 0, high index = 9
Choose element with index (0+9)/2 = 4
Compare value (10) to target
10 is greater than 5, so the target must be in the lower
half of the array
Set high index = (4-1) = 3
Loop 2
Low index = 0, high index = 3... [continues]

### Cite This Essay

APA

(2012, 03). Bubble Sort. StudyMode.com. Retrieved 03, 2012, from http://www.studymode.com/essays/Bubble-Sort-929895.html

MLA

"Bubble Sort" StudyMode.com. 03 2012. 03 2012 <http://www.studymode.com/essays/Bubble-Sort-929895.html>.

CHICAGO

"Bubble Sort." StudyMode.com. 03, 2012. Accessed 03, 2012. http://www.studymode.com/essays/Bubble-Sort-929895.html.