Professional Documents
Culture Documents
CS204-2020-Spring - Final
CS204-2020-Spring - Final
1:00 pm ~ 3:00 pm
Part / 32
I
Part / 28
II
Part / 15
III
Part / 35
IV
Part / 30
V
Total / 140
1
Student Id: Name:
Part I. (Logic)
1. (4 pts) Let P be a predicate over elements of type T. Assume you can test elements for
equality. Write predicates to capture the following English sentences.
2. (6 pts) Give English translations for each of the following assertions and explain how
the two are related, assuming P is some predicate.
(a) (xy)P(x,y)
(b) (y)(x)P(x,y)
2
Student Id: Name:
(P Q) (Q R)
SQ
S (P R)
3
Student Id: Name:
(1) (6 pts) Translate the above argument into predicate logic statements. Use the following
predicates:
S(x): x is a student.
M(x): x is a member.
W(x): x is welcome.
(3) (7 pts) If your answer to (2) is yes, formally prove using the Natural Deduction inference
rules in the previous page. If your answer to (2) is no, provide an interpretation (i.e.
construct a model) that will refute the validity of the argument.
4
Student Id: Name:
1. (8 pts)
(b) Describe the equivalence classes (with respect to the relation R above).
5
Student Id: Name:
2. (10 pts)
A tree T is a graph with the root node r such that from any non-root node v there is a unique
path from r to v. Prove that if T is a tree with n vertices then T has n - 1 edges.
3. (10 pts) Let A = {a, b, c}. Use Hasse diagrams to describe all partial orderings on A for
which a is a minimal element.
6
Student Id: Name:
1. (15 pts)
Let S be the subset of the set of ordered pairs of integers defned recursively by
Recursive Step) If (a,b) S , then (a,b+1) S, (a+1, b+1) S, and (a+2, b+1) S.
(a) List the elements of S produced by the first four applications of the recursive definition.
(b) Use strong induction on the number of applications of the recursive step of the definition
to show that a 2b whenever (a, b)S.
7
Student Id: Name:
1. (8 pts) A bag contains 4 red balls and 6 green balls. Three balls are chosen randomly from
the bag, without replacement.
(a) What is the probability that all three balls are red?
(b) Suppose that you win $10 for each red ball drawn and you lose $5 for each green ball
drawn. Compute the expected value of your winnings.
2. (7 pts) It is known that all items produced by a certain machine will be defective with
probability 0.1, independently of each other. What is the probability that in a sample of
three items, at most one will be defective?
8
Student Id: Name:
3. (10 pts) Consider two bags. The first contains two white and seven black balls, and the
second contains five white and six black balls. We flip a fair coin and then draw a ball
from the first bag or the second bag depending upon whether the outcome was heads or
tails. What is the conditional probability that the outcome to the toss was heads given that
a white ball was selected?
9
Student Id: Name:
4. (10 pts) Suppose that a town has the population of 100 and 10 of them are infected with
coronavirus. Assume that currently I am not infected and that if I meet with a group of one or
more people that includes a infected person then I will get infected.
(a) What is the probability that I will get infected when I meet with one person?
(b) What is the probability that I will get infected when I meet with two persons?
(c) What is the probability that I will get infected when I meet with three persons?
10
Student Id: Name:
1. (7 pts)
(a) Does this graph have an Euler circuit? Why or why not?
(b) Does this graph have an Euler path? Why or why not?
(c) The graph below is a copy of the above graph, but with some additional edges added so
that all of the vertices in the resulting graph have degree four.
11
Student Id: Name:
2. (8 pts)
in that order.
12
Student Id: Name:
3. (15 pts) Describe an algorithm that takes as input a list of n integers in non-decreasing
order (that is, for any two successive elements x and y of the list, x y is true) and
produces the list of all values that occur more than once in the input list.
13