Docsity

Midterm Exam 2 Solutions - Mathematics Algorithm and Systems Analysis | CSE 21, Exams of Computer Science

Toggle sidebar
bg1
Name:
Student ID:
CSE 21
Midterm #2 Solutions
November 17, 2009
Each problem is worth 20 points. Show your work, especially on decision trees. Also, make
sure you write legibly so that I have a chance of being able to read your solutions! Additional
scratch paper is available at the front of the room. This is a CLOSED BOOK test. However,
you may use one 81/2 by 11 inch sheet of paper with hand-written notes (on both sides).
You can use a calculator if you wish but it shouldn’t be necessary since answers can be left
in unexpanded form, i.e., using ! and x
y. Remember, you are at least as smart as your
neighbor so it won’t help you to see what he or she thinks! Good luck!
Prob. Score
1
2
3
4
5
Total
1
pf3
pf4
pf5

Partial preview of the text

Download Midterm Exam 2 Solutions - Mathematics Algorithm and Systems Analysis | CSE 21 and more Exams Computer Science in PDF only on Docsity!

Name: Student ID:

CSE 21

Midterm #2 Solutions

November 17, 2009

Each problem is worth 20 points. Show your work, especially on decision trees. Also, make sure you write legibly so that I have a chance of being able to read your solutions! Additional scratch paper is available at the front of the room. This is a CLOSED BOOK test. However, you may use one 8 1/2 by 11 inch sheet of paper with hand-written notes (on both sides). You can use a calculator if you wish but it shouldn’t be necessary since answers can be left in unexpanded form, i.e., using! and

(x y

. Remember, you are at least as smart as your neighbor so it won’t help you to see what he or she thinks! Good luck!

Prob. Score

Total

  1. Give explicit closed form solutions to the following recurrences:

(a) an+2 = 3an+1 + 4an, with a 0 = 0, a 1 = 1;

(b) bn+2 = 4bn+1 − 4 bn, with b 0 = 0, b 1 = 1.

(a) The characteristic polynomial of the recurrence relation is a^2 − 3 a−4, which has roots {− 1 , 4 }, yielding template solution an = α(−1)n^ + β 4 n. To satisfy the base cases, form the system of linear equalities

α + β = 0 −α + 4β = 1,

which has (ncessarily unique) solution α = − 1 / 5 , β = 1/5, meaning the closed form is an =

4 n 5 −^

(−1)n

(b) The characteristic polynomial is b^2 − 4 b + 4, which has just a single root 2. Thus the template solution is α 2 n^ + βn 2 n, and the resulting system of linear equalities (to satisfy the base cases) is

α + 0β = 0 2 α + 2β = 1.

Thus α = 0, β = 1/2, and the closed form is

bn = n 2 n−^1.

  1. An urn contains 2 Red marbles and 3 White marbles. A fair coin is flipped. If the coin comes up Heads, 2 Red and 1 White marbles are added to the urn. On the other hand, if the coin comes up Tails, 1 Red and 1 White marble are removed from the urn. A random ball B is now drawn from the urn.

(a) What is the probability that B is Red?

(b) What is the probability that B is White, given that the coin flip was Heads?

(c) What is the probability that the coin flip was Heads, given that the drawn ball B was White?

Let R denote the event that the ball is red (thus Rc^ is the event that the ball is white), and let H denote the event that the coin flip comes up heads (and Hc^ is the event that it comes up tails). (a) P (R) = P (R|H)P (H) + P (R|Hc)P (Hc) =^4 8

+^1

(b) P (Rc|H) =^4 8

=^1

(c) (By Bayes’ theorem,)

P (H|Rc) = P^ (R

c|H)P (H) P (Rc) =

(^4812) 1 − 125

=^37.

  1. Ann, Bob and Chuck are shooting basketball free throws. Ann is the best and makes 80% of her free throw attempts. Bob is not as good but still makes 60% of his attempts. Chuck is the worst and only makes 40% of his attempts. They each shoot one free throw.

(a) What is the probability that all three of them make their free throws?

(b) What is the probability that at least two of them their free throws?

Let A, B, C denote the events that Ann, Bob, and Chuck make their shot, respec- tively. Note that these events are independent, thus (for example) P (A, B, C) = P (A)P (B)P (C). (a) P (A, B, C) = P (A)P (B)P (C) =^4 ·^3 ·^2 53

(b) One way is to say

P (A, B, C) + P (Ac, B, C) + P (A, Bc, C) + P (A, B, Cc) = 5−^3 (4 · 3 · 2 + 1 · 3 · 2 + 4 · 2 · 2 + 4 · 3 · 3) = 82 125

Alternatively, note that

P (A, B, C) + P (Ac, B, C) + P (A, Bc, C) + P (A, B, Cc) = P (A, B) + P (B, C) + P (A, C) − 2 P (A, B, C) = 5−^3 (5(4 · 3 + 3 · 2 + 4 · 2) − 2(4 · 3 · 2)) = 12582.

Scratch paper