































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
































Overview
Below is a collection of problems that relate to topics in discrete mathematics. I encourage you to solve some of them. If you find, after a sincere effort, that you need hints to find a solution or that you simply need the answer to be explained to you, then use the time honored method: Ask an oracle, perhaps Pythia, (a nondeterministic Turing machines)^1 to provides the answer, and 1 I am not an oracle. I cannot always give the right answer to your questions. Some questions have no answers. I have not mastered the answers to many questions that do have answers.
you, the validator (a deterministic Turing machine)^2 checks it is correct.
(^2) I don’t mean to imply anyone is deter- ministic, I don’t believe that. I am just trying to describe computational ideas in anthropomorphic terms.
You can choose to earn extra credit by solving these problems, but there are rules.
Students seek extra credit for many reasons:
There are many types of students: To many to enumerate, but let me address the major classes
Logic
0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 10.
Full addition requires carry-in and carry-out bits. In general, you must be able to add two terms (bits) a and b and a carry-in bit cin to compute a sum bit s and a a carry-out bit cout.
(a) Complete the truth table below that describes a full adder: The Boolean function that adds two bits a, b, and a carry-in bit cin to produce a sum bit s and a carry-out bit cout.
Input Output a b cin s cout 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1
(b) Find a Boolean expression that represents the sum function. (c) Find a Boolean expression that represents the carry-out function. (d) Explain how you would use Boolean operations to add two 8-bit strings a = a 7 a 6 · · · a 1 a 0 and b = b 7 b 6 · · · b 1 b 0 together with a sequence of carries c = c 7 c 6 · · · c 1 c 0 to product a sum s = s 7 s 6 · · · s 1 s 0 and carry out bit c 8.
8 discrete mathematics homework
bool f(bool p, bool q, bool r) { if (p) { if (q) { return r; } return true; } return true; }
One student suggested this refactoring:
bool f(bool p, bool q, bool r) { if (p && q) { return r; } return true }
Another suggested the code should be written as:
bool f(bool p, bool q, bool r) { if (p) { return r; } if (q) { return r; } return true;
Are the code fragments functionally equivalent? Which do you think is the more beautiful code?
Sets
( 7 k
) = k! (^) k!( 7 7 − k)! = 7 · 6 · · · ( 7 − k + 1 ) = 7 k
is called 7 falling 2. In general, nk^ is called falling factorial: n falling k.
(e) Show that for n ≥ 0 ∑^7
k= 0
k!
k
n k
k= 0
7 k
n k
= 7 n
where 7k^ = 7 · 6 · · · ( 7 − k + 1 ).
X = {{0, 1} , {2, 3} , {4, 5}}
(b) How many choice functions could you define on the set X in prob- lems 3a? (c) Let Z = {nk : k ∈ Z }. Let X be the collection
X = { Z : n ∈ N }
Give an example of a choice function on X.
Sequences
pn = p(n) =
m∑− 1
k= 0
aknk
(a) Let p(n) = an + b be a linear polynomial, and let
〈l 0 , l 1 , l 2 ,.. .〉 = 〈b, a + b, 2a + b,.. .〉
be an arithmetic sequence. Show that ln − ln− 1 = a for n ≥ 1. (b) Let p(n) = an^2 + bn + c be a quadratic polynomial, and let
〈q 0 , q 1 , q 2 , q 3.. .〉 = 〈c, a + b + c, 4a + 2 b + c, 9a + 3 b + c,.. .〉
be a quadratic sequence. Show that qn+ 1 − 2 qn + qn− 1 = 2 a for n ≥ 1. (c) Let p(n) = an^3 + bn^2 + cn + d be a cubic polynomial, and let
〈c 0 , c 1 , c 2 ,.. .〉 = 〈d, a + b + c + d, 8a + 4 b + 2 c + d, 27a + 9 b + 3 c + d,.. .〉
be a cubic sequence. Show that cn+ 2 − 3 cn+ 1 + 3 cn − cn− 1 = 6 a for n ≥ 1. (d) Generalize the pattern you have discovered.
14 discrete mathematics homework
(d) But there is another problem. A dollar today may not be equal to a dollar tomorrow. Assume there is a constant 3% rate of inflation. The value of n dollars today has a future value of only n/1.03 in one year. Using this model on the value of money, how long must you work at ABC?
〈〈 0 〉 , 〈0, 1〉 , 〈0, 1, 3, 2〉 , 〈0, 1, 3, 2, 6, 7, 5, 4〉 , 〈0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8〉 ,.. .〉
(a) How are the sequences generated? (b) Describe the property of the sequences.
16 discrete mathematics homework
column j = 0 through j = i + 1 of the integer partition triangle.
Partition numbers p(n, k) k 0 1 2 3 4 5 6 7 8 9 0 0 1 0 2 0 3 0 n 4 0 5 0 6 0 7 0 8 0 9 0
p (^) j− 1 , p (^) j
where p (^) j− 1 < p (^) j. The pair is a descent if p (^) j− 1 > p (^) j. For instance,
Let
〈n k
be the number of permutations of n values with k ascents. From 〈n k
〉 is the Eulerian number called “n ascent the above example, you know^ k.” 〈 3 0
In general, there is only one permutation of n values with no ascents
〈n − 1, n − 2,... , 0〉 so
n 0
And, there is only one permutation of n values with n − 1 ascents
〈0, 1,... , n − 1 〉 so
n n − 1
k= 0
n k
= n! (1)
recursion 17
n n − k − 1
= (k + 1 )
n − 1 k
n − 1 k − 1
xk+ 1 =
xk + n xk
, k ≥ 0, x 0 = 1.
(a) Compute terms x 1 , x 2 , x 3 , and x 4 , for n = 1, 2, 3, 4. (b) What values does the recursion compute?
Summations
x
y = sin x
In this case,
2 =
∫ (^) π
0
sin xdx
≈ π 4
sin 0 + sin π/ 4 2
π 8
The trapezoid rule for uniform step size h = (b − a)/n can be written using the notation ∫ (^) b
a
f (x) dx ≈ h 2
∑^ n−^1
k= 0
( f (xk+ 1 ) + f (xk))
h 2 ( f (x 0 ) + 2 f (x 1 ) + 2 f (x 2 ) + · · · + 2 f (xn− 1 ) + f (xn))
where x 0 = a xn = b and xk = xk− 1 + h for k = 1,... , n Use the trapezoid rule to approximate the area under the curves below. What is the error? (a) y = x^2 from x = 0 to x = m using a step size of h = 1. y^ =^ x^2
x
(b) y = x^2 from x = 0 to x = m using a step size h = m/n. (c) y = 1 /x from x = 1 to x = m using a step size h = 1.