CSE 21 - Fall 2014
Homework #4 Solutions
1 Five boys and three girls are throwing Frisbees. Each boy has one Frisbee
and throws it to a random girl. What is the probability that each of the
girls gets at least one of the thrown Frisbees?
To nd the probabi
CSE 21
Practice Exam for Midterm 2
Answer Key
Spring, 2015
1. Representing Problems as Graphs I have $10, and I plan to spend some or all of my money on three
types of candy, which I will buy one piece at a time:
chocolate bars cost $3,
almond rocca cos
CSE 21 - Fall 2013
Homework #6
Homework 6 Solutions
1 Of 360 male and 240 female employees at the Flagstaff Mall, 260 of
the men and 150 of the women are on ex-time (exible working hours).
Given that an employee selected at random from this group is on ex
1
Homework #2
Homework 2 Solutions
1.In how many ways can 8 students be seated in a row of 8 chairs if Jason
insists on sitting in the rst chair?
Solution: In this problem we have 8 chairs. We also have 8 students to place
in the 8 chairs. One of them, Ja
HW1 Solutions
CSE 21, Fall 2014
1. A vendor sells ice cream from a cart on a sidewalk in Mission Bay. He oers 5 dierent
avors (such as vanilla, chocolate, or green tea) served on 4 dierent kinds of cones.
How many dierent single-scoop ice-cream cones can
HW3 Solutions
CSE 21, Fall 2014
1. How many ways are there to distribute 10 red jellybeans and 8 blue jellybeans to 4
girls and 3 boys if:
(a) There are no restrictions?
Solution:
16
6
14
6
The stars and bars formula, n+k1 , tells us the number of ways to
How to use strong induction to prove correctness
of recursive algorithms
April 12, 2015
1
Format of an induction proof
Remember that the principle of induction says that if p(a)k[p(k) p(k +1)],
then k Z, n a p(k). Here, p(k) can be any statement about the
CSE 21
Practice Final Exam
Spring, 2015
1. Order questions.
For each of the following pairs of functions f and g, choose whether f o(g), f (g), or f (g)
(exactly one will be true).
(a) f (n) = n, g(n) = 2
log n
(b) f (n) = log(n4 ), g(n) = (log n)4 .
(c)
Expected Value, Independence,
and Randomized Algorithms
Russell Impagliazzo and Janine Tiefenbruck
May 22, 2015
Todays agenda
1
Review conditional distributions from last class
2
Introduce expected values of distributions
3
Dene independent random distrib
Hash Functions; Variance
Russell Impagliazzo and Janine Tiefenbruck
May 29, 2015
Todays agenda
1
Introduce the ideal random hash function model.
2
Show how the element distinctness problem can be solved in
linear time using this model.
3
Show how to pick
Randomized Algorithms
Russell Impagliazzo and Janine Tiefenbruck
May 27, 2015
Todays agenda
1
Apply probability theory to bound the expected time of a
randomized algorithm to nd the ith largest element in an
array
2
Introduce the ideal random hash functio
CSE 21: Answers to Practice Final
1) (a) g (n) = (b) h(n) = 5 7 1 2 12 3 13 1 2 13 3+ 2 13
n
13 + 1 + 2 13
3
2
13
n
.
3 1 n 4n . 4 5 2 12 3 7 1 5 3 12 3 5 4
2) 1
+2
+3
=
3) (d) f g h 4) 63.
n
5) In binomial theorem (a + b)n =
k=0
n k nk ab , set a = 3,
CSE 21 FA07 Practice Final December, 2007 There are 15 problems here. The Final could have fewer problems and will be a CLOSED BOOK test. However, you may bring along two 8 1/2 by 11 inch sheets of paper with handwritten notes on both sides, if you w
Solutions to the Sample Final 1. Find general solutions to the following two recurrences: (a) g(n+2)=3g(n+1)+g(n), n 0 , where g(0) = 1, g(1)=1. Using the Theorem 9 in the book on page 135 to solve this problem:
3 13 . 2 So, the general form is g (n) = K1
Solutions to the Sample Final 1. Find general solutions to the following two recurrences: (a) g(n+2)=3g(n+1)+g(n), n 0 , where g(0) = 1, g(1)=1. Using the Theorem 9 in the book on page 135 to solve this problem:
3 13 . 2 So, the general form is g (n) = K1
CSE 21A
CSE21 Practice Problem Solutions
December 10, 2014
The following problems are good practice for the Final Exam. It is very likely the almost
all of the problems on the Final will be closely related to some of these problems. I have
sketched soluti
CSE 21 - Fall 2013
Homework #5
Homework 5 Solutions
1 How many permutations of p of cfw_1,2,3,4,5 are there such that |p (k)
p (k + 1)| 2 for 1 k 4?
This problem asks that for a permutation of cfw_1,2,3,4,5, the value of a digit
in position k must be with
CSE 21 - Fall 2013
Homework #7
Homework 7 Solutions
Disclaimer: Even though it is not done in these solutions, any time you
think you nd a solution to a recurrence relation, you should prove that
its actually the solution. You can do this by induction.
1
CSE 21 Winter 2008 Final Exam Solutions
Roy Liu
University of California at San Diego
1
a By guessing that
n n g(n) = r1 + r2 ,
we get 0 = r2 - 5r + 6 r {2, 3}. Applying initial conditions, we get that g(0) = 0 = + g(1) = 1 = 2 + 3 = -1 =1