CS111 Introduction to Computer Science
Recitation 4
Exercise 1: Find the Bug(s)
Warmup:
Declaration/Assignment
Boolean expressions
int x = 5
double = a;
char f = g;
boolean b = true;
if ( boolean = true)
if ( var = true)
if ( boolean = false)
if ( var
Solutions to Chapter 2 Exercises SOLVED EXERCISES
S1. (a) Assuming a sufficient supply of yogurt is available for all shoppers, each shopper is
simply making a decision. If some flavors of yogurt were in short supply, then it would be a game, because shop
Solutions to Chapter 7 Exercises SOLVED EXERCISES
S1. False. A players equilibrium mixture is devised in order to keep her opponent indifferent
among all of her (the opponents) possible mixed strategies; thus, a players equilibrium mixture yields the oppo
Solutions to Chapter 4 Exercises SOLVED EXERCISES
S1. False. A dominant strategy yields you the highest payoff available to you against each of your
opponents strategies. Playing a dominant strategy does not guarantee that you end up with the highest of a
Solutions to Chapter 5 Exercises SOLVED EXERCISES
S1. (a) Rs best-response rule is given by y = 10x x. L spends $16 million, so x = 16. Then
Rs best response is y = 1016 16 = 10(4) 16 = 40 16 = 24, or $24 million. (b) simultaneously: x = 10(10x x)1/2 10x
Solutions to Chapter 3 Exercises SOLVED EXERCISES
S1. (a) There is one initial node (I) for Hansel making the first move; three decision nodes (D)
including the initial node, which represent the points where either Hansel or Gretel make a decision; and si
Solutions to Chapter 6 Exercises SOLVED EXERCISES
S1. Second-mover advantage. In a sequential game of tennis, the second mover will be able to
respond best to the first movers chosen action. Put another way, the second mover will be able to exploit the in
Solutions to Chapter 8 Exercises SOLVED EXERCISES
S1. False. A players equilibrium mixture is devised in order to keep her opponent indifferent among
all of her (the opponents) possible mixed strategies; thus, a players equilibrium mixture yields the oppo
Binomial theorem
(x+y)^n=(sum of values from 0 to n of nCk)(x^k)(y^(n-k)
You can split objects into groups by forming set k=n1 and forming a set
n-k=n2 of the objects that you left out of the first set. Sum of the
number of objects remain n.
(N over n1,n2
nchoosek=binomial coefficient
NPk=nCk*k!
NC0=1=0!, there's only one way of picking nothing
NCN=1=N!/N!, there's only one way of picking everything if order
doesn't matter (u pick everything)
Binomial theorem
(x+y)^n=(sum of values from 0 to n of nCk)(x^k)
640:47703
SPRING 2014
SOLUTIONSASSIGNMENT 8
Chapter 4. Problems: p. 164 #19. The size of the jump in F at a point gives the probability
that X takes that valuei.e., probability mass function at that point. At other places the
probability mass function is
Maths 4250-Spring 2008
Take-Home Assignment # 4 with solutions
Due Date: In-Class on 02/13/2008
Your solutions must appear in an organized and legible format to be
given full consideration.
Instructions:
1. (ex11 pp125) A total of n independent tosses of
640:47703
SPRING 2014
SOLUTIONSASSIGNMENT 1
Chapter 1. Problems: p. 15 #1. The rst two places can be chosen in 26 26 ways and the last 5 in
10 10 10 10 10 ways; the product is 6.76 108 . With no repetitions, the choices would number
26 25 10 9 8 7 6 1.965
640:47703
SPRING 2014
SOLUTIONSASSIGNMENT 4
Chapter 2. Problems: p. 49 #15. For all of these problems, we must count the number of ways to
choose the type of hand in question, then divide by 52 to nd the probability.
5
4
13
1 ways to choose the suit and t
640:47703
SPRING 2014
SOLUTIONSASSIGNMENT 2
Chapter 2. Problems: p. 48 #1. S = cfw_RR, RG, RB, GR, GG, GB, BR, BG, BB
S = cfw_RG, RB, GR, GB, BR, BG
p. 48 #2. A typical point in the sample space might look like 5 1 3 5 5 2 6; this means that we
rolled the
640:47703
SPRING 2014
SOLUTIONSASSIGNMENT 5
Chapter 3. Problems: p. 97 #1. Let E be at least one 6, F be dierent numbers. There
are 36 outcomes, 6 in which the two dice are the same and hence 30 in which they are dierent,
so P (F ) = 30/36 = 5/6. There ar
640:47703
SPRING 2014
SOLUTIONSASSIGNMENT 6
Chapter 3. Problems: p. 101 #49a. The events are: C: has cancer; H healthy; Y : test says cancer.
P (C|Y ) =
(.268)(.7)
P (Y |C)P (C)
=
.
P (Y |C)P (C) + P (Y |H)P (H)
(.268)(.7) + (.135)(.3)
p. 102 #55. Suppose
640:47703
SPRING 2014
SOLUTIONSASSIGNMENT 7
Chapter 3. Problems: p. 105 #81. This is gamblers ruin with n = 30, i = 15 and p = 0.55, so the
1
1 (0.45/0.55)15
=
0.953026559 .
probability of winning is
30
1 (0.45/0.55)
1 + (9/11)15
c
p. 105 #82. (a) Let Sk
640:47703
SPRING 2014
SOLUTIONSASSIGNMENT 9
Chapter 4. p. 165 #27. Let IE be the indicator function of E; then X = A IE + C is the random
variable that gives their prot. Thus we need 0.1 A = E[X] = A p + C or C = (0.1 + p) A as
the cost of the policy to t
640:47703
SPRING 2014
SOLUTIONSASSIGNMENT 10
Chapter 4. Problems: p. 166 #40. The number X of correct answers is a binomial random variable
with parameters (5, 1/3), since the probability of a correct guess on any question is 1/3. Thus
P cfw_X 4 =
5
4
1
3
Stats
Words="words"=combination of letters, doesn't have to be real word
Permutation=arrangements of objects, N# where all objects are used
once and ORDER MATTERS, sampling without replacement
Combination=combinations of objects, sampling with replacement