{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

L5post - Previous Lecture Branching Boolean...

Info icon This 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!
Image of page 1

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

View Full Document Right Arrow Icon
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
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 e d t o re p e at many t rials !
Image of page 3

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

View Full Document Right 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
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
Image of page 5

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern