{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw8 - CS 473 Algorithms Fall 2010 HW 8(due Tuesday November...

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

CS 473: Algorithms, Fall 2010 HW 8 (due Tuesday, November 2) This homework contains four problems. Read the instructions for submitting homework on the course webpage . In particular, make sure that you write the solutions for the problems on separate sheets of paper; the sheets for each problem should be stapled together. Write your name and netid on each sheet. Collaboration Policy: For this home work, Problems 1-3 can be worked in groups of up to 3 students each. Problem 0 should be answered in Compass as part of the assessment HW8-Online and should be done individually. 0. (10 pts) HW8-Online on Compass. 1. (35 pts) Suppose we want to write an efficient function Shuffle( n ) that returns a permutation of the set { 1 , 2 , ..., n } chosen uniformly at random. (a) Prove that the following algorithm is not correct.[Hint: Consider n = 3.] Algorithm Shuffle ( n ) 1. for i 1 to n 2. do π [ i ] i 3. for i 1 to n 4. do swap π [ i ] π [Random( n )] 5. return π [1 . . . n ] (b) Prove that the following implementation of Shuffle( n ) is correct. What is its expected

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

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