This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: then the key is at this location. key 25 Last Updated: 06/02/12 10:23 PM CSE 2011 Prof. J. Elder  49  If key not in original list If the key is contained in the original list, then the key is contained in the sublist. • Loop invariant true, even if the key is not in the list. • If the key is contained in the original list, then the key is at this location. 3 5 6 13 18 21 21 25 36 43 49 51 53 60 72 74 83 88 91 95 key 24 • Conclusion still solves the problem. Simply check this one location for the key. Last Updated: 06/02/12 10:23 PM CSE 2011 Prof. J. Elder  50  Running Time The sublist is of size n, n / 2 , n / 4 , n / 8 , … ,1 Each step O(1) time. Total = O(log n) key 25 3 5 6 13 18 21 21 25 36 43 49 51 53 60 72 74 83 88 91 95 If key ≤ mid , then key is in left half. If key > mid , then key is in right half....
View
Full
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.
 Fall '11
 Elder
 Data Structures

Click to edit the document details