L5post - Previous Lecture: Branching Boolean operations...

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

View Full Document Right Arrow Icon
± Previous Lecture: ± Branching ± Boolean operations (relational, logical) ± Today’s Lecture: ± Iteration using for ± Announcements ± Proj 1 due tonight at 11pm. Submit in CMS now, don’t wait! ± Simulated prelim 1 on 9/30, 7:30-9pm. Optional . ± Use office hours or consulting hours if you have questions ± Register your clicker!
Background image of page 1

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

View Full DocumentRight Arrow Icon
Top-Down Design State problem Define inputs Design algorithm Convert algorithm to program Test and debug An algorithm is an idea . To use an algorithm you must choose a programming language and implement the algorithm. Decomposition Stepwise refinement
Background image of page 2
September 10, 2009 Lecture 5 4 Question A stick of unit length is split into two pieces. The breakpoint is randomly selected. On average, how long is the shorter piece? Physical experiment? Thought experiment? Æ analysis Computational experiment! Æ simulation N e d t o r p a m n y i l s !
Background image of page 3

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

View Full DocumentRight Arrow Icon
September 10, 2009 Lecture 5 5 Question A stick of unit length is split into two pieces. The breakpoint is randomly selected. On average, how long is the shorter piece? A: .000001 B: .25 C: .333333 D: .499999 E: none of the above
Background image of page 4
September 10, 2009 Lecture 5 7 % one trial of the experiment breakPt= rand(1); if breakPt<0.5 shortPiece= breakPt; else shortPiece= 1-breakPt; end Simulation: use code to imitate the physical experiment
Background image of page 5

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

View Full DocumentRight Arrow Icon
September 10, 2009 Lecture 5 8 % one trial of the experiment breakPt= rand(1); shortPiece= min(breakPt, 1-breakPt); Want to do many trials, add up the lengths of the short pieces, and then divide by the number of trials to get the average length.
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 25

L5post - Previous Lecture: Branching Boolean operations...

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

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