CSC151.01 2006S, Class 40: Binary Search Admin: * No reading for Friday. * But there is homework for Friday! Given the following structure (list (list "Be Mean To Elementary Kids" (list 'emilyson 'richpat)) (list "Fans of Rat-like Creatures" (list 'emilyson 'docdavis)) ) * Thursday extra tomorrow on the GIMP. EC for attending. Free pizza. Overview: * About common algorithms. * Searching. * Binary search. * Lab. /What is computer science?/ * The study of algorithms * Algorithm: A way/method/process/set of instructions to solve a problem * Why called this? Expect a pop quiz on it * We write algorithms (yes, you've been writing them) * Often: * Look for problems * Model the problem * Solve the modeled problem * Better: * Look for classes of problems * Model the class * Solve the class /Searching/ * Given a collection of "keyed records" (chunks of information with a designated key), find ones with a matching key. * Write good, general solutions to this problem * assoc * Write efficient solutions to this problem /Binary Searching/ * If the "keyed records" are stored in a vector and are organized by key from smallest to largest, we can do something more efficient. * For the Chicago yellow pages, we certainly don't want to read each name in sequence. * For the computer, one technique is to keep track of the range of the vector in which it falls (it must be after here and before here) * How much does this save? * Consider the Chicago phone book: 700 pages, 200 per page 140,000. Say 2,000,000 2,000,000 -> 1,000,000 -> 500,000 -> 250,000 -> 125,000 -> 64,000 -> 32,000 -> 16,000 -> 8,000 -> 4,000 -> 2,000 -> 1,000 -> 512 -> 256 -> 128 -> 64 -> 32 -> 16 -> 8 -> 4 -> 2 -> 1