Docsity

Discrete Math home work relation, Exercises of Discrete Mathematics

Partial preview of the text

Download Discrete Math home work relation and more Exercises Discrete Mathematics in PDF only on Docsity!

D E PA R T M E N T O F C O M P U T E R S C I E N C E S

C O L L E G E O F E N G I N E E R I N G

F L O R I D A T E C H

D I S C R E T E

M AT H E M AT I C S

H O M E W O R K

W I L L I A M S H O A F F F A L L 2 0 1 3

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.

  1. You must start earning extra credit before Monday, October 15. In par- ticular, you cannot seek extra credit toward the end of the semester once you’ve realized you will almost certainly not earn the grade you seek.
  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.
  3. You must explain your solution to the instructor’s satisfaction in a solo interview. Schedule an interview through the department’s administrative assistant: Mrs. Karen Brown.

Students seek extra credit for many reasons:

  • To improve their grade
  • To learn advanced topics
  • For future recommendation from their instructor
  • And there may be other reasons of which I have not thought.

There are many types of students: To many to enumerate, but let me address the major classes

  • To those who want to learn advanced topics, demonstrate your understand- ing as basic topics by solving these homework problems. You will earn an A in the course.

Logic

  1. It is interesting to think of False =0 and True =1 as numerical values rather than Boolean values. When you do, addition can implemented by the rules

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.

  1. In general, a Boolean function maps an n-tuple of Boolean values to an m-tuple of Boolean values, as in problem 1 where 3 values are mapped to
    1. How many different n-input, m-output Boolean functions are there?

8 discrete mathematics homework

  1. A quasi-Boolean function maps an n-tuple (p 0 , p 1 ,... , pn− 1 ) of Boolean values to one of three values: 0 = (False), 0.5 = (Maybe) or 1 = (True). (a) How many different n-variable quasi-Boolean functions are there? (b) If you allow quasi-Boolean (0, 1/2, 1) input as well, How many different n variable functions are there?
  2. Use the laws of Boolean algebra: commutative, associative, distributive, De Morgan’s, etc., and the shorthand p → q for ¬p ∨ q, to prove the following equivalences. (a) p → (q → r) ≡ (p ∧ q) → r (b) (p ∧ q) → r ≡ (p → r) ∨ (q → r)
  3. I once wrote some code that looked like this:

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

  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 k!

( 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

∑^7

k= 0

7 k

n k

= 7 n

where 7k^ = 7 · 6 · · · ( 7 − k + 1 ).

  1. 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?
  2. 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

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

  1. A polynomial sequence P~ has terms pn defined by a polynomial

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.

  1. 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 Science Department earn starting salaries from $50,000 to $70,000.
  • Company ABC offers you $50,000 plus a yearly raise of 5% of your salary.
  • Company XYZ offers you $60,000 plus a yearly raise of $3,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?

  1. Consider the sequence of sequences.

〈〈 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

  1. A permutation is a one-to-one function from a finite set onto itself. Let ~π = 〈p 0 , p 1 ,... , pn− 1 〉 be a permutation of 0 to n − 1. An ascent in a permutation is a pair

p (^) j− 1 , p (^) j

where p (^) j− 1 < p (^) j. The pair is a descent if p (^) j− 1 > p (^) j. For instance,

  • 〈0, 1, 2〉 has 2 ascents,
  • 〈2, 1, 0〉 has no ascents,
  • Each of 〈1, 0, 2〉, 〈0, 2, 1〉, 〈2, 0, 1〉, and 〈1, 2, 0〉 has one ascent.

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

  1. Explain why n∑− 1

k= 0

n k

= n! (1)

recursion 17

  1. Explain why (^) 〈 n k

n n − k − 1

  1. 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 ~π?
  2. Let ~π have k ascents. Show there are k + 1 sequences among ~πn, j, j = 0, 1,... , n − 1 that have k ascents.
  3. Let ~π have k − 1 ascents. Show there are n − k sequences among ~πn, j, j = 0, 1,... , n − 1 that have k ascents.
  4. Use your answers from the previous problems to explain the three-term recurrence equation 〈 n k

= (k + 1 )

n − 1 k

  • (n − k)

n − 1 k − 1

  1. Let n be a natural number greater than 0. Consider the sequence generated by the recurrence equation

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

  1. The area under a curve can be approximated by the trapezoid rule. 4 4 How can you compute the area of a For instance the area under the sine curve from x = 0 to x = π can be trapezoid? approximated by 4 trapezoids with base h = π/4 and heights sin kπ/4, k = 0, 1, 2, 3, 4.

x

y = sin x

In this case,

2 =

∫ (^) π

0

sin xdx

≈ π 4

sin 0 + sin π/ 4 2

  • sin^ π/^4 +^ sin^ π/^2 2
  • sin^ π/^2 +^ sin 3π/^4 2
  • sin 3π/^4 +^ sin^ π 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.