Sei sulla pagina 1di 4

CSE 20 Fall 2014 - Study guide for Final Exam

The final exam time and location depends on your lecture section:
A00 (8am lecture) Mon 12/15 8am-11am Center 101
B00 (9am lecture) Wed 12/17 8am-11am Galbraith 242
You must attend the lecture time for which you are enrolled since seats will be assigned
ahead of time.
You may use one (double-sided, letter size, handwritten) sheet of notes during the exam.
The exam covers all the material discussed during the course. In particular, you should
study:
Jenkyns and Stephenson Sections 1.1, 1.2, 1.3 , 2.1, 2.2, 2.3.1, 2.3.2, 2.3.5, 3.2, 3.3, 3.4,
3.5, 3.6, 3.7.1, 3.7.3, 3.7.4, 6.1, 6.2, 6.3, 6.4.2.
All questions in all HWs and WQs, including the warmup questions from the textbook
that were assigned with each HW. Also go over clicker questions and examples from
class, the examples from Discussion Sections, and the exam study guides from Exam
1 and Exam 2.
Its a good idea to go over the feedback you received on the homework, and also to
look over the homework and quiz solutions posted on Ted.
Additional questions to work on:
0. Compile a list of the basic definitions and facts from this course and prepare your note
sheet for the exam.
1.
(a) Show that the following Boolean expressions are all equivalent:
p (q r)

(p q) r

(p r) q

Note: you can use either truth-tables or identities; or try both!


(b) Use the equivalences established above to rewrite the following sentence (in words)
in two additional different ways.
For every integer n, if n is prime, then n is odd or n is 2.

2. Compute the following conversions:


(a) 2014 from (unsigned) decimal to (unsigned) octal, i.e. base 8.
(b) A2BC from (unsigned) hexadecimal to (unsigned) binary.
(c) 11010011 from eight-bit twos complement to (signed) decimal.
3.
(a) How many symbols are required to represent a positive integer in ternary (unsigned base 3) if its representation in (unsigned) base 9 uses exactly 10 symbols?
(b) Write out the pseudo-code of the algorithm for the conversion from unsigned
decimal representation to unsigned base 9.
4. Find a Boolean expression (using Boolean variables p,q,r) whose truth-table is given
by the table below.
p q r Output
T T T
T
T T F
F
T F T
T
T F F
T
F T T
F
F T F
F
F F T
F
F F F
F
Is there only one expression that works?
5. For each of the following statements and domains (i) translate the statements to English, (ii) decide whether the statement is True or False over the given domain, and
(iii) briefly justify your answer.
(a) xy( x y ), over the set of all integers.
(b) xy( x y ), over the set of positive integers.
(c) xy( y x ), over the set of positive rational numbers.
(d) xy( y x ), over the set of positive real numbers.
6. Twenty questions: Describe an algorithm (in English and in pseudocode) to solve
the following problem.
Given an integer between 1 and 2000, guess its value using only questions of the form
is the number bigger than .... (where the dots can be filled in by any number you
choose). The algorithm must use at most 20 questions (no matter what the input is).
Hint: your algorithm can use principles from binary representations of positive integers.

7. Consider the following algorithm whose input is a positive real number a.


Begin
y 1.0;
z a;
While ( z 1 ) Do
y y a;
z z 1;
End;
Output y;
End.
(a) What is the output of this algorithm for input a = 3.14? You must show enough
of the trace / walkthrough of the algorithm to justify your answer.
(b) Let zk be the value of z after the k th iteration of the while-loop. Prove by Mathematical Induction on k that
For any nonnegative integer k, after k iterations of the while-loop, zk = a k.
Use this invariant to prove that the algorithm must always terminate (no matter
what the input value a is).
(c) Describe the output of this algorithm as a function of a. Briefly justify your
answer.
8. Consider the following identity for any positive integer n:
n(n 1)(n + 1)
.
3
P Q
(a) Write the left-hand-side of the identity using
or notation (you need to decide
which one is appropriate).
1 2 + 2 3 + + (n 1) n =

(b) Prove the identity using induction on n.


9. A robot starts at the origin and moves on an infinite two-dimensional integer grid. At
each time step, the robot can move to one of the four diagonally adjacent grid points
(see lecture slides on 11.14.14 for diagram). Prove by mathematical induction that the
sum of the coordinates of any state reachable by the robot is even.
Note: reachable means reachable by any finite sequence of steps.
10. Prove or disprove the following statements. Make sure to state any definitions and/or
proof strategies you are using.
(a) For any set A, A.
(b) For any set A, A P(A).

(c) There is a bijection between the set {2, 3, 5, 7, 11, 13, 17, 19} and the set {a, b}
P({a, b}).
For parts (d) and (e) we study the following function whose inputs are binary
strings and whose outputs are also binary strings. The function f : {0, 1}
{0, 1} is defined (recursively) by
(
if s =
f (s) =
w if s = w0 or s = w1, where w is some binary string
(d) The function f is one-to-one.
(e) The function f is onto.
(f) For any integer n, n(n2 1)(n + 2) is divisible by 4.
11. Let S = {n Z : n 2}. We define a binary relation R on S by
xRy

iff

gcd(x, y) > 1.

(a) Is R reflexive, symmetric, anti-symmetric, transitive? Justify your answer for


each.
(b) Using your answers for part (a), classify R as an equivalence relation and/or an
order relation and/or a partial order and/or a total order and/or none of the
above.
12. A set S = {1, 2, 3, 4, 5} of jobs to be completed has some dependencies. We write
xRy

iff

either x = y or x must be completed before we can do y.

Suppose we are given that


R = {(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (1, 3), (1, 4), (1, 5), (2, 4), (2, 5), (3, 5)}
(a) Prove that R is a partial order on S.
(b) Draw the Hasse diagram for S.
(c) If one person is to perform all these jobs, find an order in which the jobs can be
done. Is there only one way to do this?
(d) If an element is minimal in this partial order, what does that mean about how
we can schedule it? What about maximal elements?
13. Prove that the set {0, 1} N has the same size as N by specifying a bijection f :
{0, 1} N N. (You need to define the function f and then also prove that it is both
one-to-one and onto.)
Solutions will not be distributed for these practice problems (other than the ones already
available for homework). It is often much more productive to figure out for yourself how to
start a problem and then ask for help if and when you get stuck.

Potrebbero piacerti anche