3/06 monster lecture sketch: 0. overview of monster lecture sketch ! contains many examples and explanations not given in lecture -- too many to mark ! contains material to be presented on thursday: please skim beforehand _______________________________________________________________________________ 0. overview of monster lecture sketch 0.0 contents 0.1 announcements, reminders, topics, topics for next lecture 0.2 loop invariant (review + new analogy) 1. introduction to the maximum subsequence sum problem 1.0 problem statement -- english specification 1.1 example 1.2 elaboration of english specification (terminology review & introduction) 1.3 problem statement -- technical specification 1.4. goal: a short and efficient solution 2. (3/08 preview) analyzing program performance 2.1 terminology and concepts for analyzing program performance 2.2 concrete example comparing $100 n^2$ and $n^3/10$: 2.3 big-Oh notation ("big-Oh" stands for "the capital letter `O'"): 2.4 simple examples of analyzing programs 2.5 easier way to get time complexity (when you get used to it): 2.6 analyzing programs that process a sequence, e.g. an input sequence 3. naive and better solutions to max subsequence sum 3.0 general problems with simple solutions to max subsequence sum 3.1 naive solution 3.2 (3/08 preview) performance of naive solution 3.3 better solution 3.4 (3/08 preview) performance of better solution 4. sophisticated solution to maximum subsequence sum 4.0 memorize and use template for processing input with a stopping value! 4.1 first technique to try: answer so far 4.2 introspection (how *we* do it) 4.3 zeroth --> second technique to try: maintain info. about previous value 4.4 code for sophisticated solution 5. $makepoly$ and $evalpoly$ examples from E8.1/P4.2; error-checking 5.1 loop invariant example: $makepoly$ 5.2 loop invariant example: $evalpoly$ 5.3 error-checking with multiple versions 5.4 error-checking with inverses 5.5 connections with P4.2: use error-checking ideas above in $testpoly$ _______________________________________________________________________________ 0.1 announcements, reminders, topics, topics for next lecture Announcement: + see notes on "error-checking" for techniques to use for $testpoly$ + resubmitting $testpoly$ will not take away early bonus Reminders + run posted code! look again at early Lecture Sketches! + Course & T1 evaluation: today is the last day + T2 is coming up: + let us know *now* of any conflicts + topics, review questions will be posted later this week + review session is this sunday + P4: online submission only; submit running code! + E9 has been posted Topics + loop invariant (review + new analogy) + more loop invariant examples: + 3 solutions to max subsequence sum: naive, better, sophisticated + makepoly + evalpoly + error-checking: resubmitting $testpoly$ will not take away early bonus Topics for 3/08 lecture: + coping with problems: + look at the line that matlab claims contains the error + comment out (or cut out and save) portions of code to locate error + display values + hand *and* computer trace + $keyboard$ command + debugger + analyzing program performance _______________________________________________________________________________ 0.2 loop invariant (review + new analogy) + alternate name: loop *storyline* or *plotline* + intent: explanation of *what* loop does + not necessarily an explanation of *how* the loop does it + technically: a condition that is true whenever the loop guard is tested + usually does not explicitly explain how to make progress + can be as simple as + "maintain variable definitions above" + a clear picture analogy: + loop invariant is true = we are at one of many "safety zones" + whenever loop guard is tested, we must be at one of the safety zones + during execution of the loop body, + we (usually) leave the safety zone to make "unsafe/dangerous" progress + we can leave and return to safety zones multiple times + by the end of the loop body, we have gone back to a safety zone rough baseball analogy: + safety zone = any of the 4 bases + make progress = run to a later base, including stealing a base