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

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

View Full Document Right Arrow Icon
CSE 143 Lecture 6 (b) Binary Search reading: 13.1 slides created by Marty Stepp http://www.cs.washington.edu/143/
Background image of page 1

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

View Full DocumentRight Arrow Icon
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 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
Background image of page 2
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 2 7 1 0 1 5 2 0 2 2 2 5 0 3 6 4 2 5 0 5 6 6 8 8 5 9 2 3 min mid max
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 The  Arrays  class
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/04/2011 for the course CSE 143 taught by Professor Sr during the Spring '08 term at University of Washington.

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 Right Arrow Icon
Ask a homework question - tutors are online