Name:
CSE 1400
Spring 2015
Applied Discrete Mathematics
Practice Quiz 1 Key
‘
1. Pretend you need to assign names (IDs) to a group of people. You can choose the alphabet. Pretend
your IDs will be n symbols long. How many people can you name using these alphabets?
(a) The bits B
Answer: There are 2n bit strings of length n. So, 2n names can be given out.
(b) The digits D
Answer: There are 10n decimal strings of length n. So, 10n names can be given out.
(c) The 36 symbols in the Klingon alphabet pIqaD of letters and numerals.
Answer: There are 36n Klingon strings of length n. So, 36n names can be given out.
It is good to notice the similarities of these problems to problem 10.
2. Show these compression relationships are True.
2n = 10n log 2 = 36n log36 2
That is, all the things that can be named in n bits could be named in about n/3 digits or about n/5
Klingon symbols.
You will find this easy if you understand logarithms and mysterious if you don’t. But compression is
a fundamental idea, so I thought I’d mention it.
Answer: Note that 10log 2 = 2 because
log 2 = y
means 2 = 10y = 10log 2
Therefore, 10n log 2 = 2n . In a similar manner, 36log36 2 = 2 because
log36 2 = y
means 2 = 36y = 36log36 2
Therefore, 36n log36 2 = 2n .
Your calculator will tell you that log 2 ≈ 0.3010 and log36 2 ≈ 0.1934. Therefore decimal names are
about 1/3 the length of binary names and Klingon names are about 5 times shorter than binary names.
3. Arithmetic tells us when an integer a is divide by a natural number m > 0, a quotient q and remainder
r are computed and they satisfy the equation
a=m·q+r
or
r
a
=q+
m
m
where 0 ≤ r < m
Given a and m, compute the quotient q and remainder r.
(a) a = 73 and m = 13.
Answer: q = 5 and r = 8. Notice 73 = 13 · 5 + 8.
(b) a = −73 and m = 13.
Answer: q = −6 and r = 5. Notice −73 = 13 · (−6) + 5.
4. Consider the five digit strings: 00000 to 99999. Think of these strings as integers written in ten’s
complement notation.
1
(a) What is the value of (27181)10c ?
Answer: (27181)10c = 27181.
(b) What is the value of (57722)10c ?
Answer: (57722)10c = −42278.
(c) Write the negative of (57722)10c in 10’s complement notation.
Answer: − (57722)10c = 42278 = (42278)10c .
5. You are to design a Boolean function (a circuit) that has 3 (Boolean) input values: a, b, and c and a
single (Boolean) output d.
(a) How many different input combinations are there?
Answer: There are 23 = 8 different inputs: From 000 to 111.
This number, 8, is the size (cardinality) of the input space, called the domain of the function, a
generic symbols for domain is X. There are only two values in the output space: {True, False}.
The output space is called the co-domain or range of the function and it is often named Y.
(b) How many different functions could be designed?
3
Answer: There are 22 = 28 = 256 different functions. (You should be able to compute 28 = 256.
It is the size of the address space of a byte.)
For each input combination there are two possible outputs: False or True. Therefore there are
28 different functions.
The number 2 is the size of the output space {0, 1} = {False, True}, often called the co-domain
or range of the function and labeled Y.
The number of functions from X to Y can be computed by the expression
|X|
28 = |Y|
where |X| is the size (cardinality) of the domain and |Y| is the size (cardinality) of the co-domain.
(c) The function you are to design is given by the truth table below. Find a Boolean expression
(function) that computes it.
Input
Output
Row
a
b
c
d
1
2
3
4
5
6
7
8
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
0
1
0
0
0
0
1
Answer: Take each row where the output D is 1. Form an AND-clause of the input in that row
to make the output True. Form the OR of each of these clauses. For the table above:
d = (¬a ∧ b ∧ ¬c) ∨ (a ∧ b ∧ c)
This can be factored, but I dare to ask that. b must be True, so
d = b ∧ ((¬a ∧ ¬c) ∨ (a ∧ c))
and this simplifies to
d = b ∧ (a ≡ c)
That is, b is True and a and c are equivalent.
2
6. Fill in the truth assignments and four column truth table for the Boolean expression
¬(¬p ∨ q) ≡ p ∧ ¬q
Input
Computations
p
q
column 1
¬
column 2
(p ∧ ¬q)
columm 3
≡
column 4
¬p ∨ q
0
0
1
1
0
1
0
1
1
1
0
1
0
0
1
0
1
1
1
1
1
1
0
1
(a) I don’t ask that you memorize many words, but what is the name of the law applied in the
equivalence ¬(¬p ∨ q) ≡ p ∧ ¬q?
Answer: This is an application of one of De Morgan’s laws. They are usually stated as
¬(p ∨ q) ≡ ¬p ∧ ¬q
or
¬(p ∧ q) ≡ ¬p ∨ ¬q
The question is a minor modification.
(b) Use the equivalence (¬p∨q) ≡ (p ⇒ q) write an English statement explaining ¬(¬p∨q) ≡ p∧¬q.
Answer: Here’s one way to say this: First, ¬(¬p ∨ q) means ¬(p ⇒ q) which means p does not
imply q. And, if p does not imply q, then p must be True and q must be False, because truth
should never produce falsehood.
Conversely, if p is True and q is False, then p does not imply q.
7. There were three basic functions we found useful.
(a) Increment: 0, 1, 2, 3, . . .
You could write n 7→ n or id(n) = n (the next value is one more than the current value).
(b) Double: 1, 2, 4, 8, . . .
You could write n 7→ 2n or d(n) = 2n (the next value is twice the current value).
(c) Square: 2, 4, 16, 256, . . .
n
n
You could write n 7→ 22 or s(n) = 22 (the next value is the current value squared).
Use I (increment), D (double), or S (square) to describe which function described these things?
(a) The number of Boolean variables.
Answer: This is I : The number of variables
goes up by 1.
(b) The number of subsets within a universe.
Answer: This is I : The number of subsets
goes up by 1.
(c) The number of truth assignments.
Answer: This is D: The number of truth assignments doubles when another variable is
included.
(d) The number of Boolean functions.
Answer: This is S : The number of Boolean
3
functions squares when another variable is included.
(e) The number of regions in a diagram of fully
intersecting sets.
Answer: This is D: The number of regions
doubles as a new set is included in the diagram.
(f) The number of diagram shadings on fully intersecting sets.
Answer: This is S : The number of shading
squares as a new set is included in the diagram.
8. I’ve heard computer engineers are lazy, Please don’t identify me as saying this! But sometimes computer
engineers don’t care about input or output signals. They will accept any of three values for input
or output: DC = {0, 1/2, 1}, standing for False, don’t care, and True, How many n-variable input,
1-value output functions are there from DCn to DC?
n
Answer: There are 33 functions. There are 3n ways to assign values to n values from {False, don’t care, True}
and there are 3 ways to map each of the values.
9. Construct a truth table for the Boolean expression
(q ⇒ p) ⇒ (p ⇒ (p ∧ q))
Answer:
Input
Output
p
q
(q ⇒ p)
⇒
(p ⇒
(p ∧ q))
0
0
1
1
0
1
0
1
1
0
1
1
1
1
0
1
1
1
0
1
0
0
0
1
10. How many digits are needed to write a natural number n?
Answer: The approximate answer is log10 n where log10 (·) is the logarithm base 10, often called the
common logarithm.
You know this if you think about it. To write a number from 0 to 9 requires one digit. It takes two
digits to write 10 to 99, and 3 digits to write 100 to 999. This growth in digits is logarithmic as a
function of the number written.
The more precise answer is
blog10 nc + 1 the floor of the log (base 10) of n, plus 1.
Notice that any positive integer m ≥ 1 can be bounded by powers of 10.
1 ≤ m < 10,
10 ≤ m < 100,
100 ≤ m < 1000, . . . , 10n−1 ≤ m < 10n
In these cases, the number m can be written in 1, 2, 3, . . . n digits.
Use these bounds and take the common logarithm of the inequalities to get
(n − 1) ≤ log m < n
Round log m down to its floor, (n − 1), to compute the number of digits needed to write m.
n = blog mc + 1
For different bases use different logarithm bases.
It is good to notice the similarities and differences between this problem and problem 1.
11. Here’s some exercises/questions.
(a) Simplify 2n + (2n − 1).
Answer: There are 2 (2’s to the n) and a minus 1. That is, 2n + (2n − 1) = 2 · 2n − 1 = 2n+1 − 1.
(n − 1)(n − 2)
+ (n − 1).
(b) Simplify
2
Answer: Factor the common term (n − 1) out:
(n − 1)(n − 2)
n−2
+ (n − 1) = (n − 1)
+1
2
2
4
Add the terms left in brackets:
(n − 1)
n−2
n
n(n − 1)
+ 1 = (n − 1) =
2
2
2
(c) Is ∅ = {∅}?
Answer: No, the empty set is the the same as the set containing the empty set. The set ∅ has no
members. You can see the set {∅} has one element.
Some use this notation for the empty set: ∅ = {}. Then, the question asks: Does {} look like
{{}}? I hope you say no.
(d) Is ∅ ⊆ {∅}?
Answer: This is True. Because there are no elements in ∅ every one of them is in {∅}.
During an exam, it is not uncommon for students to ask what ⊆ means. I chose not to answer.
Math is recognizing similarities, patterns. The symbol ⊆ looks like ≤. How would you interpret
less than or equal in the context of sets?
(e) There are round things and pointy things. The symbols ∧, ∨, ∪ , ∩ , ⇒ , ≤, ⊆ are used in logic,
arithmetic, and set theory. In which field (logic, arithmetics, or set theory) are they used. What
do they mean? What are the natural equivalences between them?
Answer: Consider The Point! The story of Oblio the round headed boy banished from the Pointed
Village to the Pointless Forest because he had no point.
12. Odious, pernicious, and Mersenne are interesting numbers. Looking only at the digits D = {0, 1, 2, . . . , 9}
here are the definitions.
• Odious digits have an odd number of 1’s in their binary expansion. What are the odious digits?
Answer: The odious digits are 1, 2 = 10, 4 = 100, 7 = 111, and 8 = 1000. The digits 0, 3 = 11,
5 = 101, 6 = 110, and 9 = 1001 are not odious.
O = {1, 2, 4, 7, 8} .
• A number is pernicious if the sum of the bits in its binary representation is a prime number.
What are the odious digits?
Answer: The pernicious digits are
P = {3, 5, 6, 7, 9} .
Notice that the sum of bits in 3 = 11, 5 = 101, 6 = 110, 7 = 111, 9 = 1001 is either 2 or 3. And,
the sum of bits in 0 = 0, 1 = 1, 2 = 10, 4 = 100, and 8 = 1000 is not a prime number.
• Mersenne numbers have the form 2n − 1 for n = 0, 1, 2, . . .. Except for 0, every bit is 1 in the
binary representation of a Mersenne number. A Mersenne number is the largest value that can
be written in a given number of bits. What are the Mersenne digits?
Answer: The Mersenne digits are
M = {0, 1, 3, 7} .
5
(a) Fill in the Venn diagram below using the odious (O), pernicious (P), and Mersenne (M) digits.
Answer:
D
P {5, 6, 9}
{3}
∅
{2, 4, 8} {7}
O {1} M{0}
(b) What set expression described the diagram
D
P
O
M
Answer: The shaded part of O can be written as
O ∩ ¬M ∩ ¬P
The shaded parts of M and P can be written as similar expressions. The final answer is the union
these expressions.
(O ∩ ¬M ∩ ¬P) ∪ (M ∩ ¬O ∩ ¬P) ∪ (P ∩ ¬M ∩ ¬O)
Notice the similarity with problem 5c.
Total Points: 0
Thursday, January 29, 2015
6
© Copyright 2026 Paperzz