Docsity

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

Toggle sidebar
bg1
Midterm 1, CSE21, Fall 2001
Student Name:
SOLUTIONS
Instructions:
Begin by writing your name above.
This is a closed book and notes exam. You may not use calculators.
The exam contains one problem with seven questions, one problem with
nine questions and an extra credit problem. Try them all. Write your
answers on the exam sheet itself, in the assigned space below the problem,
or on the extra blank page that follows.
Suggestions:
Scan through the entire exam before beginning any ques-
tion. You don't have to do the questions in order: do rst whatever you
nd easiest. We suggest you do the extra credit problem last, due to its
diculty.
Guidelines:
Remember to write clearly: answers that don't make sense
will not get much credit. You are graded on what you write, not on what
you think you mean! So read carefully what you write. Also, indicate with a
brief note the application of the Rule of Product, Rule of Sum, and inclusion-
exclusion principle. It will help you get partial credit if the nal answer is
wrong. When computing probabilities in equiprobable spaces indicate the
size of the universal set and the size of the event set.
Important Note:
For all problems answers like
n
!,
,
n
k
,
n
m
k
are
ne. HOWEVER, in multiple choices that ask for the specic number,
calculations have to be done.
Good luck!
1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

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

Midterm 1, CSE21, Fall 2001

Student Name: SOLUTIONS

Instructions: Begin by writing your name ab ove. This is a closed b o ok and notes exam. You may not use calculators. The exam contains one problem with seven questions, one problem with nine questions and an extra credit problem. Try them all. Write your answers on the exam sheet itself, in the assigned space b elow the problem, or on the extra blank page that follows.

Suggestions: Scan through the entire exam b efore b eginning any ques- tion. You don't have to do the questions in order: do rst whatever you nd easiest. We suggest you do the extra credit problem last, due to its diculty.

Guidelines: Rememb er to write clearly: answers that don't make sense will not get much credit. You are graded on what you write, not on what you think you mean! So read carefully what you write. Also, indicate with a brief note the application of the Rule of Pro duct, Rule of Sum, and inclusion- exclusion principle. It will help you get partial credit if the nal answer is wrong. When computing probabilities in equiprobable spaces indicate the size of the universal set and the size of the event set.

Imp ortant Note: For all problems answers like n!,

n

k

, n  m  k are ne. HOWEVER, in multiple choices that ask for the sp eci c numb er, calculations have to b e done.

Go o d luck!

Scores: To b e lled in at grading time.

On Problem You got Out of

Total: 85

co ecient we have:

3 ; 1 ; 1

= (^) 3!5!1!1! = 53 ^42 ^31 ^21 ^11 = 5 ^42 ^2 ^1 , which is option iii.

(d) Win 4, don't lose 1 A student group contains 4 girls and 3 b oys. Yannis randomly cho oses a committee of 4 students. What is the probability that the committee contains exactly 2 girls and 2 b oys? i. (^1835) ii. 21018 iii. 21090 iv. cannot tell given the ab ove information v. none of the ab ove Solution: The size of the universal set is: jU j =

4

To nd the size of the event set we break the problem up into the following steps: i. select 2 girls out of 4. ii. select 2 b oys out of 3. Using the Rule of Pro duct: jE j =

2

2

. So the probabilty P (E ) is: P (E ) = jjEU jj = (

( 74 ) =^

4! 2!2! ^ 3! 7!2!1! 4!3!

= 4!2!4!2!3!2!3!7! = 1835 , which is option i. (e) Win 4, don't lose 1 Consider the function f from the domain set fa; b; cg to the range set f 1 ; 2 ; 3 g, such that f (a) = 1 ; f (b) = 3 ; f (c) = 3. Is the function f a i. surjection ii. injection iii. bijection iv. cannot tell given the ab ove information v. none of the ab ove Solution: Function f is not a surjection, b ecause f ^1 (2) = fg. Is not a injection, b ecause f (b) = f (c) = 3. So it can not b e a bijection either. So we cho ose option v. (f ) Win 4, don't lose 1 Consider again the function f from the domain set A = fa; b; cg to the range set B = f 1 ; 2 ; 3 g, such that f (a) = 1 ; f (b) = 3 ; f (c) = 3. The generalized inverse f ^1 : B 7! P (A), in the two-line notation is

i. (

fag fg fb; cg

ii. ( a b c fag fg fb; cg

iii. (

a fg b c

iv. none of the ab ove Solution: It's not option iii, b ecause f ^1 is a function and its domain denoted by the rst line can not have rep etitions, like the 3 that ap ears two times. It's not option ii, b ecause the domain of f ^1 is f1,2,3g and not fa,b,cg as the rst line denotes. It is option i from the de nition of the generalized inverse function f ^1 of a function f.

(g) Win 4, don't lose 1 Consider two functions f and g , where f is de ned as: f (1) = 5,f (2) = 4,f (3) = 1,f (4) = 3,f (5) = 2, and g is de ned as: g (1) = 2,g (2) = 3,g (3) = 1,g (4) = 4,g (5) = 5. The (f  g ), or (f g ), is: i. (f g )(1) = 1,(f g )(2) = 2,(f g )(3) = 3,(f g )(4) = 4,(f g )(5) = 5 ii. (f g )(1) = 5,(f g )(2) = 4,(f g )(3) = 3,(f g )(4) = 2,(f g )(5) = 1 iii. (f g )(1) = 4,(f g )(2) = 1,(f g )(3) = 5,(f g )(4) = 3,(f g )(5) = 2 iv. (f g )(1) = 2,(f g )(2) = 3,(f g )(3) = 5,(f g )(4) = 1,(f g )(5) = 4 v. none of the ab ove Solution: It's option iii, b ecause (f g )(1) = f (g (1)) = f (2) = 4. You get the rest in a similar way.

(c) 3 p oints What is the probability that the hand contains exactly 2 aces, the \Queen of Diamonds" and two other cards that are not aces? Solution: To nd the size of the event set we break the problem up into the following steps:  First we select 2 aces out of four.  Next we select the \Queen of Diamonds".  Finally, we select 2 cards out of the remaining 47. Using the Rule of Pro duct: jE j =

2

1

2

So the probabilty P (E ) is:

P(E) =

jEj jUj

2

1

2

5

(d) 6 p oints What is the probability that the hand contains exactly 2 aces, the \Queen of Diamonds" or the \Queen of Hearts" (but not b oth) and two other cards that are not aces? Solution: To nd the size of the event set we break the problem up into the following steps:  First we select 2 aces out of four.  Next we select 1 card to b e either the \Queen of Diamonds" or the \Queen of Hearts".  Finally, we select 2 cards out of the remaining 46. Using the Rule of Pro duct: jE j =

2

1

2

So the probabilty P (E ) is:

P(E) =

jEj jUj

2

1

2

5

(e) 5 p oints What is the probability that the hand contains 2 aces, 2 kings, and 1 queen? Solution: To nd the size of the event set we break the problem up into the following steps:  First we select 2 aces out of four.  Next we select 2 kings out of four.  Finally, we select 1 queen out of four.

Using the Rule of Pro duct: jE j =

2

2

1

So the probabilty P (E ) is:

P(E) =

jEj jUj

2

2

1

5

(f ) 4 p oints What is the probability that the hand contains exactly 2 aces, exactly 2 kings, and a fth card that is not an ace or a king? Solution: To nd the size of the event set we break the problem up into the following steps:  First we select 2 aces out of four.  Next we select 2 kings out of four.  Finally, we select 1 card out of the remaining 44. Using the Rule of Pro duct: jE j =

2

2

1

So the probabilty P (E ) is:

P(E) =

jEj jUj

2

2

1

5

(g) 6 p oints What is the probability that the hand contains exactly 2 aces or exactly 2 kings? (Hint: It's not exclusive or) Solution: To nd the size of the event set we break the problem up into the following cases:  E 1 The hand contains exactly 2 aces.  E 2 The hand contains exactly 2 kings.  E 1 \ E 2 The hand contains exactly 2 aces and exactly 2 kings. The size of the event set for each case is: jE 1 j =

2

3

, jE 2 j =

2

3

, jE 1 \ E 2 j =

2

2

1

Using the inclusion-exclusion principle, the probabilty P (E ) is:

P(E) =

jE 1 j + jE 2 j jE 1 \ E 2 j jUj

2

3

2

2

1

5

(h) 6 p oints What is the probability that the hand contains at least 2 aces and at least 2 kings? Notice that the fth card may or may not b e an ace or a king. Solution: To nd the size of the event set we break the problem up into the following events:

  1. Extra Credit Problem (10 p oints) There are 6 di erent colored pairs of so cks [1 green, 1 blue, 1 red, 1 yellow, 1 orange, 1 purple], 12 so cks in all.

 (a) 4 p oints If 2 so cks are selected at random, what is the probability that the so cks are a matching pair, i.e., b oth are the same color? Solution: There are

2

ways to select 2 so cks from a set of 12 so cks. There are 6 p ossible outcomes that are matched pairs. Therefore, the probability of selecting two so cks that are a pair is P =

2

:

 (b) 6 p oints If the 12 so cks are to b e distributed into 6 b oxes, each of which is to contain exactly 2 so cks, what is the probability that all b oxes contain matched pairs (ie. the red pair is in one b ox, the blue pair is in another, etc.)? (Hint: Though it is not necessary, it may help to think that the b oxes are ordered.) Solution: First we want to partition 12 so cks into 6 groups of 2. We know from our ordered paritions that there are

12 2 ; 2 ; 2 ; 2 ; 2 ; 2

ways to do so. Then, there are 6! ways to arrange the pairs in these 6 b oxes, so the probability that all b oxes contain a pair is

P =

12! 26

: