{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

L5post

L5post - Previous Lecture Branching Boolean...

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

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!

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

View Full Document
Top-Down Design State problem Define inputs & outputs 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
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 e d t o re p e at many t rials !

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

View Full Document
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
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

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

View Full Document
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.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern