Map Hash Tables and Dictionaries_Part_13

Map Hash Tables and Dictionaries_Part_13 - Boundary...

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

View Full Document Right Arrow Icon
Last Updated: 06/02/12 10:23 PM CSE 2011 Prof. J. Elder - 61 - 25 13 74 Boundary Conditions key 25 95 91 88 83 72 60 53 51 49 43 36 21 21 18 6 5 3 If key mid , then key is in left half. If key > mid , then key is in right half. •Another bug! No progress toward goal: Loops Forever! mid Select mid 2 pq + ⎡⎤ = ⎢⎥
Background image of page 1

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

View Full DocumentRight Arrow Icon
Last Updated: 06/02/12 10:23 PM CSE 2011 Prof. J. Elder - 62 - if [ mid ] 2 1 else end key A mi pq q mid p d + ⎢⎥ = ⎣⎦ =+ = Boundary Conditions if [ mid ] 2 1 else end + ⎡⎤ = = if < [ mid 2 1 ] else end A mid + = = = OK OK Not OK!!
Background image of page 2
Last Updated: 06/02/12 10:23 PM CSE 2011 Prof. J. Elder - 63 - if [ mid ] 2 1 else end key A mi pq q mid p d + ⎢⎥ = ⎣⎦ =+ = How Many Possible Algorithms? mid r 2 o? + ⎡⎤ = if < [ or ? ] A mid else o end 1 r = =
Background image of page 3

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

View Full DocumentRight Arrow Icon
Last Updated: 06/02/12 10:23 PM CSE 2011 Prof. J. Elder - 64 - <precondition>: A[1. .n] is sorted in non-decreasing order <postcondition>: If is in A[1. .n], algorithm returns 1, its location loop-invariant>: If is BinarySea in rch(A[1. .n], whil ) e pq key qp e n ky < > == 2 retur A[1. .n n(mid) ], then if = [ ] elseif < is
Background image of page 4
Background 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 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.

Page1 / 5

Map Hash Tables and Dictionaries_Part_13 - Boundary...

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