demo-bsearch - 8 2 1 3 4 6 5 7 10 9 11 12 14 13 64 14 13 25...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 8 2 1 3 4 6 5 7 10 9 11 12 14 13 64 14 13 25 33 51 43 53 84 72 93 95 97 96 6 Binary Search lo Binary search. Given value and sorted array a , find index i such that a[i] = value , or report that no such index exists. Invariant. Algorithm maintains a[lo] value a[hi]. Ex. Binary search for 33. hi Binary Search Binary search. Given value and sorted array a , find index i such that a[i] = value , or report that no such index exists. Invariant. Algorithm maintains a[lo] value a[hi]. Ex. Binary search for 33. 8 2 1 3 4 6 5 7 10 9 11 12 14 13 64 14 13 25 33 51 43 53 84 72 93 95 97 96 6 lo hi mid Binary Search Binary search. Given value and sorted array a , find index i such that a[i] = value , or report that no such index exists....
View Full Document

This note was uploaded on 06/25/2009 for the course MATH MAT 400 taught by Professor Jamespotvein during the Fall '08 term at University of Toronto- Toronto.

Page1 / 9

demo-bsearch - 8 2 1 3 4 6 5 7 10 9 11 12 14 13 64 14 13 25...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online