Homework
Homework
COLLEGE OF ENGINEERING
FLORIDA TECH
DISCRETE
M AT H E M AT I C S
HOMEWORK
WILLIAM SHOAFF FA L L 2 0 1 3
Problems Sets
Overview 5
Logic 7
Sets 11
Sequences 13
Recursion 15
Summations 19
Induction 21
Relations 23
Functions 25
Proofs 35
Index 39
Overview
2. You must present a nicely written solution to the problem. For extra, extra
credit learn to write mathematics in a document processing system such as
LATEX or (sigh) Word. A system that can nicely typeset mathematical, and
other, notations.
There are many types of students: To many to enumerate, but let me address
the major classes
• Your C + score
C + = 10z + 79
which assumes an average student will be at the C+/B- cutoff.
• The median m that partitions the scores into two equal-sized groups:
Those below m and those above m.
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
(a) p → ( q → r ) ≡ ( p ∧ q ) → r
(b) ( p ∧ q ) → r ≡ ( p → r ) ∨ ( q → r )
Are the code fragments functionally equivalent? Which do you think is the
more beautiful code?
logic 9
(∀x) (∃x)
(∃x) (∀x)
(∀y) (∃y)
Quantification
(∀x) (∃x)
(∀y) (∃y)
(∃y) (∀y)
1. Pretend you are writing traffic accident software and want to categorize
accidents by the day of the week on which they occur. Pretend there are n
accident reports to categorize.
(a) What is the size of the sample space? That is, in how many ways can
the n accident reports be distributed over 7 days?
(b) In how many ways can all n accidents occur on one single day?
(c) In how many ways can all n accidents occur on only two days?
(d) Let’s looks at the other end: In how many ways can all n accidents
occur on seven, and no less, days. Note that
!
(e) Show that for n ≥ 0 7 7
k! = k!
k k!(7 − k)!
7 !( ) X7 ( )
X 7 n n = 7 · 6 · · · (7 − k + 1)
k! = 7k = 7n
k k k = 7k
k =0 k =0
where 7k = 7 · 6 · · · (7 − k + 1).
is called 7 falling 2. In general, nk is called
falling factorial: n falling k.
2. There are 2000 students on campus who own Team Fortress 2, Plants vs
Zombies, or Kerbal Space Program. If 500 students owe all three games,
200 own only Team Fortress 2, 350 own only Plants vs. Zombies, and 150
own only Kerbal Space Program, how many of these games in total are
owned by Florida Tech students?
3. The axiom of choice states that for any collection X of nonempty sets,
then there exists a choice function c() that selects an element of A for
every set A ∈ X.
(a) Give an example of a choice function on the collection
(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}
C0 = [0, 1]
1 2 C0 2 + C0
C1 = [0, ] ∪ [ , 1] = ∪
3 3 3 3
1 2 1 2 7 8 C1 2 + C1
C2 = [0, ] ∪ [ , ] ∪ [ , ] ∪ [ , 1] = ∪
9 9 3 3 9 9 3 3
Cn−1 2 + Cn−1
Cn = ∪
3 3
m−1
X
pn = p ( n ) = ak nk
k =0
hl0 , l1 , l2 , . . .i = hb, a + b, 2a + b, . . .i
hq0 , q1 , q2 , q3 . . .i = hc, a + b + c, 4a + 2b + c, 9a + 3b + c, . . .i
2. You have just graduated from Florida Tech with a BS in computer science
or software engineering. Two companies have offered you a job. 3 3
Recent surveys show most students
graduating from Florida Tech’s Computer
• Company ABC offers you $50,000 plus a yearly raise of 5% of your Science Department earn starting salaries
salary. from $50,000 to $70,000.
(a) All other benefits being equal and assuming long term employment,
which company’s offer would you accept?
(b) Does your salary from ABC ever exceed your salary from XYZ?
(c) How long would you need to stay at ABC until your total earnings
equaled your total earnings from XYZ?
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?
hh0i , h0, 1i , h0, 1, 3, 2i , h0, 1, 3, 2, 6, 7, 5, 4i , h0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8i , . . .i
The terms in a partition are called parts. Let p(n, k) denote the number of
partitions of n into exactly k parts. For example, 6 can be partitioned into
k = 1, 2, 3, 4, 5 and 6 parts in the following ways.
p(n, k) = p( x, y) + p(z, w)
where x and z are smaller than n, and y and w are no greater than k. Be
able to explain why your recursion is sensible.
(b) Use your recursion formula to fill in the row i = 0 to row i = 9 and
16 discrete mathematics homework
* + * + * +
3 3 3
= 1, = 4, =1
0 1 2
3. Explain why
n−1 * +
X n
= n! (1)
k
k =0
recursion 17
4. Explain why * + * +
n n
= . (2)
k n−k−1
5. Let ~π be a permutation of n values: 0 to n − 1. Develop a notation for
the permutation that results from inserting a new value n into ~π and some
position j. In how many ways can you insert a new value n into ~π?
6. Let ~π have k ascents. Show there are k + 1 sequences among ~πn, j , j =
0, 1, . . . , n − 1 that have k ascents.
7. Let ~π have k − 1 ascents. Show there are n − k sequences among ~πn, j ,
j = 0, 1, . . . , n − 1 that have k ascents.
8. Use your answers from the previous problems to explain the three-term
recurrence equation
* + * + * +
n n−1 n−1
= (k + 1) + (n − k )
k k k−1
y = sin x
In this case,
Z π
2= sin xdx
0
π sin 0 + sin π/4 sin π/4 + sin π/2 sin π/2 + sin 3π/4 sin 3π/4 + sin π
!
≈ + + +
4 2 2 2 2
π √
= (2 + 2 2)
8
≈ 1.896
The trapezoid rule for uniform step size h = (b − a)/n can be written using
the notation
Z b n−1
hX
f ( x) dx ≈ ( f ( xk+1 ) + f ( xk ))
a 2
k =0
h
= ( f ( x0 ) + 2 f ( x1 ) + 2 f ( x2 ) + · · · + 2 f ( xn−1 ) + f ( xn ))
2
1. Identify the relations on the set of bits B = {0, 1} that are partial orders
and those that are equivalence relations.
4. A candy machine takes nickels, dimes and quarters. When 50¢ is de-
posited a candy bar is dispensed along with change if necessary. The
diagram below shows the transitions from state-to-state as money is put in
the machine.
25
25
25
30 10
10 40 10|25
5 5
5 5
10 25 5 5|10|25
10 20 45 50
5 5
5 5 10
10 5 25
0 10 15 10 10
25 35
25
25
25
(a) Say that two paths p0 and p1 in the transition graph are path equiva-
lent they start in the same state and end in the same state. Prove path
equivalence is an equivalence relation.
(b) Say state s precedes state t if there is a path from s to t. (Include
trivial paths from a state to itself on input of 0¢, so that state s precedes
itself). Prove precedes is a partial order.
(a) a ≡ b (mod 2)
(b) a ≡ b (mod 1)
(c) a ≡ b (mod 0)
2. You have a picture that is 5” × 3”. You want to discretize it into an image
of 1920 × 1080 pixels. Into which pixel ( p x , p(y ) will ( x, y) fall, for
0 ≤ x ≤ 5, and 0 ≤ y ≤ 3?
You may want to start by studying the smaller 19 × 13 grid below.
(5, 3)
0
10
12
0 2 4 6 8 10 12 14 16 18
(0, 0)
1. How would you define a duovigesimal (base 32) number system? Discuss
the alphabet and modeling natural numbers, integers, and rational numbers
in fixed point and floating point notations. What is the compression in
string length when representing numbers in base 32 over base 2?
2. The powers of 2 form a basis for the natural numbers. Any natural number
n ≥ 0 can be written as the sum of powers of 2.
m−1
X
(∀n ∈ N)(∃bk ∈ B, k = 0, 1, . . . , m − 1) n =
k
bk 2
k =0
Prove this.
3. The Fibonacci numbers are another interesting base for the natural num-
bers. That is,
m−1
X
(∀n ∈ N)(∃bk ∈ B, k = 0, 1, . . . , m − 1) n = bk Fk
k =0
Prove this.
4. I got this one from Click & Clack, the Tappet Brothers: Given $1000 in $1
dollar bills and 10 envelops, distribute the money among the envelops so
that you can give out any dollar amount from $1 to $1000.
7. Write 0.1, 0.2, and 0.3 in fixed point notation as repeating binary pat-
terns. Use your ability to sum an infinite geometric series 5 to show your 5
Infinite series is not taught in this class.
answers are correct. Series is a topic in calculus, but you can
guess, know, or look up geometric series.
8. In class we’ve used an 8-bit pidgin floating point notation to explain basic
concepts in modeling real numbers by a finite set of rational numbers.
Modern floating point units are expected to implement the IEEE 754
standard for binary floating-point arithmetic. A single precision floating
point numbers are represented in 32 bits: 1 sign bit, 8 exponent bits, and
23 fraction bits.
s e7 e6 e5 e4 e3 e2 e1 byte 0
e0 f−1 f−2 f−3 f−4 f−5 f−6 f−7 byte 1
In this case,
x = (−1) s × (1. f )2 × 2e
– When e = −127 the numbers are denormalized or subnormal. When
the fraction bits are not all 0’s, the bit string represents plus or minus
0.
1. In how many ways can you find n positive integers that add up to m?
(Take the order of the terms into account, for example, 1 + 2 + 4 is different
than 2 + 4 + 1.)
2. An n-legged Alien has a drawer full of socks, each of which is red, white,
or blue, and there are at least n socks of each color. The Alien pulls out
one sock at a time without looking. How many socks must the Alien
remove from the drawer to be certain there will be n socks of the same
color?
Consider the problem again, but suppose there are m sock colors.
3. In the clock game Alice and Bob both start at 12 o’clock. During a move
Alice moves 5 hours clockwise on the clock-face and Bob moves 9 hours
counterclockwise. How many moves will it take before Bob and Alice
stop on the same hour?
What if the game is changes so that Alice moves a hours clockwise and
Bob moves b hours counterclockwise?
5. Back in the day men always wore hats and when they went to a club they
would have a hat-check girl store their hats. If n men checked hats, in how
many ways can they be returned such that no man gets back his own hat?
6. The rumor is that Blaise Pascal was very interested in gambling and
developed many of his ideas about combinatorics from that.
(a) In how many five card hands can be dealt from a standard deck of 52
cards?
A A 2 5 J
♠ ♥ ♥ ♦ ♦
♠ ♥ ♦ ♦
♥ ♥
♦
♦ ♦
♠ ♥ ♥ ♦ ♦
A A 2 5 J
A A 2 2 K
♠ ♥ ♥ ♦ ♣
♠ ♥
♥
♥
♦
♦
♠ ♥ ♥ ♦ ♣
A A 2 2 K
A A A 7 Q
♠ ♥ ♣ ♦ ♣
♠ ♣
♦ ♦
♦
♥ ♦ ♦
♦ ♦
♠ ♥ ♣ ♦ ♣
A A A 7 Q
3 4 5 6 7
♠ ♥ ♦ ♦ ♣
♠ ♥ ♥ ♦ ♦ ♦ ♦ ♣ ♣
♣
♠ ♦ ♦ ♦ ♣ ♣
♠ ♥ ♥ ♦ ♦ ♦ ♦ ♣ ♣
♠ ♥ ♦ ♦ ♣
3 4 5 6 7
3 5 10 J K
♠ ♠ ♠ ♠ ♠
♠ ♠ ♠ ♠ ♠
♠
♠ ♠
♠ ♠
♠ ♠
♠ ♠ ♠ ♠
♠ ♠
♠ ♠ ♠ ♠ ♠
3 5 10 J K
A A A 7 7
♠ ♥ ♣ ♦ ♥
♠ ♣
♦ ♦ ♥ ♥
♦ ♥
♥ ♦ ♦
♦ ♦
♥ ♥
♥ ♥
♠ ♥ ♣ ♦ ♥
A A A 7 7
A A A A 6
♠ ♥ ♣ ♦ ♣
♣ ♣
♠ ♥ ♣ ♦ ♣ ♣
♣ ♣
♠ ♥ ♣ ♦ ♣
A A A A 6
3 4 5 6 7
♠ ♠ ♠ ♠ ♠
♠ ♠ ♠ ♠ ♠ ♠ ♠ ♠ ♠
♠
♠ ♠ ♠ ♠ ♠ ♠
♠ ♠ ♠ ♠ ♠ ♠ ♠ ♠ ♠
♠ ♠ ♠ ♠ ♠
3 4 5 6 7
10 J Q K A
♥ ♥ ♥ ♥ ♥
♥ ♥
♥
♥ ♥
♥ ♥
♥
♥ ♥
♥
♥ ♥ ♥ ♥ ♥
10 J Q K A
7. Binary trees are basic data structures. A full binary tree is one where each
internal node has exactly two children.
4 8
7
And a full binary tree
34 discrete mathematics homework
1234
12 34
1 2 3 4
(a) Let T n be a full binary tree with n internal nodes. How many edges
does T n have?
(b) Let T n be a full binary tree with n internal nodes. How many leafs
does T n have? Cn is called a Catalan number.
(c) Let Cn be the number of full binary trees with n internal nodes. What
is a recurrence equation for Cn ?
(d) Let Cn be the number of full binary trees with n internal nodes. What
is a formula, involving binomail coefficients, for Cn ?
Proofs