Download Discrete Mathematics Lecture 4: Sequences and Mathematical Induction and more Slides Discrete Mathematics in PDF only on Docsity!
Discrete Mathematics
Lecture 4: Sequences
and Mathematical Induction
Sequences
- Sequence is a set of (usually infinite number of) ordered elements: a 1 , a 2 , …, an, …
- Each individual element ak is called a term, where k is called an index
- Sequences can be computed using an explicit formula: ak = k * (k + 1) for k > 1
- Alternate sign sequences
- Finding an explicit formula given initial terms of the sequence: 1, -1/4, 1/9, -1/16, 1/25, -1/36, …
- Sequence is (most often) represented in a computer program as a single-dimensional array Docsity.com
Exercises
- Consider the sequence defined by
an = (2n + (-1) n^ – 1) / 4 Find an alternative formula for an that uses floor notation
- Show that n! + k is divisible by k for all integers k no greater than n.
- Given any integer m greater than 1, is it possible to find a sequence of m – 1 consecutive positive integers none of which is prime?
Mathematical Induction
- Can we represent any amount greater than 3 cents as a combination of 2 and 5 cents?
- Principle of Mathematical Induction:
Let P(n) be a predicate that is defined for integers n and let a be some integer. If the following two premises are true: P(a) is a true ∀k ≥ a, P(k) P(k + 1) then the following conclusion is true as well P(n) is true for all n ≥ a
Exercises
- Show that 2 2n^ – 1 is divisible by 3
- Show that for n > 2: 2n + 1 < 2 n
- Show that x n^ – y n^ is divisible by x – y
- Show that n 3 – n is divisible by 6
- On the outside rim of a circular disk the integers from 1
to 30 are painted in random. Show that there must be three successive integers whose sum is at least 45
Exercises
- Show that for any integers a and b there
exist two integer u and v so that
gcd(a, b) = ua + vb
- Show that every integer greater than 1 is
divisible by a prime number
Correctness of Algorithms
- Assertions
- Pre-condition is a predicate describing initial state before an algorithm is executed
- Post-condition is a predicate describing final state after an algorithm is executed
- Loop guard
- Loop is defined as correct with respect to its pre- and post- conditions, if whenever the algorithm variables satisfy the pre-conditions and the loop is executed, then the algorithm satisfies the post- conditions as well
Correctness of Some Algorithms
pre-conditions: m ≥ 0, i = 0, product = 0
while (i < m) {
product += x;
i++;
post-condition: product = m * x
Correctness of Some Algorithms
pre-conditions: a ≥ 0, d > 0, r = a, q = 0
while (r ≥ d) {
r -= d;
q++;
post-conditions: a = q * d + r, 0 ≤ r < d