{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

06b-binarysearch

# 06b-binarysearch - CSE143 Lecture6(b BinarySearch...

This preview shows pages 1–5. Sign up to view the full content.

CSE 143 Lecture 6 (b) Binary Search reading: 13.1 slides created by Marty Stepp http://www.cs.washington.edu/143/

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 Sequential search sequential search : Locates a target value in an array/list by  examining each element from start to finish. How many elements will it need to examine? Example: Searching the array below for the value  42 : Notice that the array is sorted.  Could we take advantage of this? inde x 0 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 16 valu e -4 2 7 1 0 1 5 2 0 2 2 2 5 3 0 3 6 4 2 5 0 5 6 6 8 8 5 9 2 10 3 i
3 Binary search (13.1) binary search : Locates a target value in a  sorted   array/list by  successively eliminating half of the array from consideration. How many elements will it need to examine? Example: Searching the array below for the value  42 : inde x 0 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 16 valu e -4 2 7 1 0 1 5 2 0 2 2 2 5 3 0 3 6 4 2 5 0 5 6 6 8 8 5 9 2 10 3 min mid max

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 The  Arrays
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

06b-binarysearch - CSE143 Lecture6(b BinarySearch...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online