
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Four problems from a university-level computer science course, cmsc 351, homework 7. The problems involve calculating the sum of a sequence using non-integral methods and integrals, analyzing the expected gain, variance, and standard deviation of a carnival game, and finding the expected number of exchanges and comparisons in the bubble sort algorithm for different input distributions.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Summer 2009 CMSC 351: Homework 7 Clyde Kruskal
Due at the start of class, Friday, June 26.
Problem 1. For this problem you may use a calculator for a few calculations.
Consider
ā 100 k=1 k
(a) Use a non-integral method to show that the sum is between 15,000 and 70,000. (b) Approximate the sum using integrals. Make sure to get an upper and lower bound.
Problem 2. A carnival game consists of three dice in a cage. A player can bet a dollar on any of the numbers 1 through 6. The cage is shaken, and the payoff is as follows. If the playerās number doesnāt appear on any of the dice, he loses his dollar. Otherwise if his number appears on exactly k of the three dice, for k = 1, 2 , 3, he keeps his dollar and wins k more dollars.
(a) What is his expected gain from playing the carnival game once? (b) What is the variance from playing the carnival game once? (c) What is the standard deviation from playing the carnival game once? (d) What are his expected gain, variance, and standard deviation from playing the carnival game n times?
Problem 3. Consider the bubble-sort algorithm, for an input (a b c) of the three integer values 1, 2, and 3 in any order, where all input orders are equally likely (uniform distribution).
(a) Let M be the number of exchanges. What are E(M ), Var(M ), and Ļ(M )? (b) Let x be the number of comparisons. What are E(M ), Var(M ), and Ļ(M )? (c) What percentage of the sample space is within a standard deviation of average.
Problem 4. Again consider the bubble-sort algorithm, for an input (a b c) of the three integer values 1, 2, and 3 in any order. But now suppose the input orders are not equally likely; instead, there is a 1/5 chance of a = 1 being the first item in the input (the 1/5 distributed equally among those inputs) and 4/5 of a not being 1 (again the 4 /5 shared equally among all these inputs).
(a) Let M be the number of exchanges. What are E(M ), Var(M), and Ļ(M )? (b) Let x be the number of data comparisons made. What are E(M ), Var(M ), and Ļ(M )? (c) What percentage of the sample space is within a standard deviation of average.