Docsity

Midterm Solutions: CSE 21, October 19, 2009 - Prof. Ronald L. Graham, Exams of Computer Science

Toggle sidebar
bg1
Name:
Student ID:
CSE 21
Midterm #1 Solutions
October 19, 2009
Each problem is worth 20 points. Show your work to the extent you think necessary. Addi-
tional 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 won’t be necessary since answers can be
left in unexpanded form, i.e., using ! and x
y. Good luck!
Prob. Score
1
2
3
4
5
6
Total
1
pf3
pf4
pf5
pf8

Partial preview of the text

Download Midterm Solutions: CSE 21, October 19, 2009 - Prof. Ronald L. Graham and more Exams Computer Science in PDF only on Docsity!

Name:

Student ID:

CSE 21

Midterm #1 Solutions

October 19, 2009

Each problem is worth 20 points. Show your work to the extent you think necessary. Addi- tional 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 won’t be necessary since answers can be left in unexpanded form, i.e., using! and

(x y

. Good luck!

Prob. Score

Total

  1. How many different arrangements are there of all the letters in the word INDISTINGUISHABLE?

4 I’s, 2 N’s, 2 S’s, and 9 letters appearing once, thus

( 17 4

i=

i 1

4!(2!)^2

9 times

  1. How many 5-digit strings can be formed using the 10 digits { 0 , 1 ,... , 9 } which have at least one duplicated digit (such as 14312, 58878 and 66977)?

The complement of “at least one duplicated digit” is “at most zero duplicated digits”. The total number of strings is 10^5 , and the total number of strings with no duplicated digits is 105 , giving the result 105 − 105.

  1. In how many ways can 12 pens and 5 notebooks be distributed to 3 boys and 3 girls if everyone gets at least one pen, and every girl gets exactly one notebook?

The handing out of notebooks and pens is not related, thus we can solve each part separately. Giving out 12 pens but ensuring that each person gets at least 1 is the same as giving each person 1 right away, and distributing the remaining 6; this is thus bars and stars, and there are (^) ( 6 + 6 − 1 6 − 1

combinations. For the notebooks, the constraint that each girl gets exactly one removes 3 notebooks and 3 people from consideration; thus, again using bars and stars, the number of ways is (^) ( 2 + 3 − 1 3 − 1

Again, these choices did not influence one another, thus the answer is their product: ( 11 5

  1. What is the sum of the first n odd integers 1 + 3 + 5 + 7 +... + (2n − 1)?

Guess the answer and prove that it is correct by mathematical induction.

The task is to obtain a closed form expression Ψ(n) =

∑n i=1(2i^ −^ 1). The first few terms are

n 1 2 3 4 Ψ(n) 1 4 9 16

From this, a good guess is

(1) Ψ(n) =

∑^ n

i=

(2i − 1) = n^2.

Note that in class we derived

∑n i=1 i^ =^

(n+ 2

, so

Ψ(n) =

∑^ n

i=

(2i − 1) = 2

∑^ n

i=

i −

∑^ n

i=

1 = n(n + 1) − n = n^2.

Proof of (1). Base case:

∑n i=1(2i^ −^ 1) = 2^ −^ 1 = 1 = 1

Inductive step:

∑n+ i=1 (2i^ −^ 1) =^

∑n i=1(2i^ −^ 1) + (2n^ + 1) =^ n

(^2) + 2n + 1 = (n + 1) (^2).

Scratch paper