Sequences, Induction & Recursion

Sequences, Induction & Recursion

CSE 1400 Applied Discrete Mathematics Sequences, Induction & Recursion Department of Computer Sciences College of Engineering Florida Tech Spring 2012 Problems labeled ! are important and must be Problems on Sequence mastered. are harder and cover interest- Background ing advanced material that is not properly part of this course. Sequences are objects on which induction and recursion are commonly applied. A sequence, written are tangential to the course but cover material that is useful ~ S = hs0, s1, s2,...i elsewhere. is an ordered list of terms sk, k = 0, 1, 2, . .. Induction is used to demonstrate that if some predicate p(sn−1) is True, then p(sn) is also True, which with a basis that p(s0) is True we can conclude that (8n 2 N)(p(sn)) is True. [p(s0) ^ (p(sn−1) ! p(sn))] ! (8n 2 N)(p(sn)) In a stronger form, to derive that p(sn) is True, induction requires several or all predicates p(sk) to be True for k < n. Recursion defines sn as a function of sn−1 or more lower order terms. ! 1. (Know basic concepts about sequences.) True or False: A sequence ha0, a1,..., an−1,...i is an or- dered list of objects, called terms. Answer: This is True. A sequence can be written ha0, a1,..., an−1,...i. The sequence is ordered in that the term at position (index) n − 1 occurs before the term at index n. 2. ! (Know basic concepts about sequences.) True or False: A sequence can contain the same term mul- tiple times. Answer: This is True: h0, 1, 1, 2, 3, 5, . .i is the Fibonacci sequence and it contains 1 twice. 3. (Know basic concepts about sequences and lists.) True or False: A list is a sequence of finite length. Answer: The term “list” used for a finite sequence. Most of the sequences we will discuss can be contin- ued indefinitely, but in computing practice finite sequence, lists, are used. For example, h0, 1, 1, 2, 3, 5, 8i is a list of length 7. The notation j~Sj is used to denote the length of a list. 4. (Know basic concepts about sequences.) True or False: hi is the empty sequence with no terms. Answer: This is the notation I would like to use for the empty sequence. 5. ! (Know some fundamental sequences.) Below are commonly occurring sequences. Describe these sequences. cse 1400 applied discrete mathematics sequences, induction & recursion 2 (a) The Alice sequence A~ Answer: A~ is the “Alice” sequence A~ = h1, 1, 1, . , 1, . .i The Alice sequence is the first column in Pascal’s triangle. The terms in the Alice sequence are the binomial coefficients n n! = = 1 0 0!n! which is the number of ways to choose no objects from a set of n objects. (b) The Gauss sequence G~ Answer: G~ is the Gauss sequence G~ = h0, 1, 2, 3, 4, 5, 6, 7, . , (n − 1),...i The terms in the Gauss sequence are the binomial coefficients n n! = = n 1 1!(n − 1)! which is the number of ways to choose 1 object from a set of n objects for n 2 N. The Gauss sequence can be computed as sums of terms in the Alice sequence. n−1 n−1 n = gn = ∑ ak = ∑ 1 k=0 k=0 (c) The Triangular sequence ~T Answer: ~T is the Triangular sequence n(n − 1) ~T = 0, 0, 1, 3, 6, 10, 15, 21, . , ,... 2 The terms in the Triangular sequence are the binomial coefficients n n! n(n − 1) = = 2 2!(n − 2)! 2 which is the number of ways to choose 2 objects from a set of n objects for n 2 N. The Triangular sequence can be computed as sums of terms in the Gauss sequence. n(n − 1) n−1 n−1 n = tn = ∑ gk = ∑ k 2 k=0 k=0 (d) The power of 10 sequence 10~ Answer: 10~ is the power of 10 sequence. 10~ = h1, 10, 100, 1000, 10000, . , 10n,...i The powers of 10 are the standard basis for writing numbers (decimal notation): 31.415 = 3 × 101 + 100 + 4 × 10−1 + 10−2 + 5 × 10−3 cse 1400 applied discrete mathematics sequences, induction & recursion 3 (e) The power of 2 sequence~2 Answer: ~2 is the power of 2 sequence. ~2 = h1, 2, 4, 8, 16, . , 2n,...i The powers of 2 are the binary basis for writing numbers (binary notation): 14.4375 = 23 + 22 + 21 + 2−2 + 2−3 + 2−4 (f) The Mersenne sequence M~ Answer: M~ is the Mersenne sequence hMi = h0, 1, 3, 7, 15, 31, 63, 127, . , (2n − 1),...i The Mersenne sequence can be computed as sums of terms in the power of 2 sequence. n−1 n k 2 − 1 = mn = ∑ 2 k=0 (g) The Fibonacci sequence ~F Answer: ~F is the Fibonacci sequence ~ F = h0, 1, 1, 2, 3, 5, 8, 13, . , ( fn−1 + fn−2),...i (h) The Harmonic sequence H~ Answer: H~ is the Harmonic sequence 1 H~ = 0, 1, 3/2, 11/6, 50/24, 274/120, . , (H − + ),... n 1 n (i) The Busy Beaver sequence ~B Answer: ~B is the Busy Beaver sequence ~B = h1, 4, 6, 13, ?i Terms in the sequence are the maximum number of 1’s that a deterministic, n state (with one addi- tional halting state), two-way infinite initially blank tape, Turing machine can write using 1 as the only non-blank tape symbol. The sequence cannot be computed. Only the first four terms have been determined. 6. ! (Know functions that enumerate some fundamental sequences.) Match the sequence with the func- tion that maps the natural numbers to terms in the sequence. ( ) = n − (a)(e) A~ (a) f n 2 1 ( ) = (b)(b) G~ (b) f n n ( ) = ( − ) (c)(c) ~T (c) t n n n 1 /2 p n p n 1+ 5 − 1− 5 ~ 2 2 (d)(a) M (d) f (n) = p 5 ~ (e)(d) F (e) f (n) = 1 cse 1400 applied discrete mathematics sequences, induction & recursion 4 7. ! (Know recurrence equations and initial conditions that enumerate some fundamental sequences.) Match the sequence with the recurrence equation and initial condition(s) that enumerate the terms in the sequence. (a)(e) A~ (a) fn = fn−1 + 1, n ≥ 1, f0 = 0 (b)(a) G~ (b) fn = fn−1 + fn−2, n ≥ 2, f0 = 0, f1 = 1 (c)(d) ~T (c) fn = fn−1 + 1/n, n ≥ 1, f0 = 0 (d)(f) M~ (d) fn = fn−1 + (n − 1), n ≥ 1, f0 = 0 (e)(b) ~F (e) fn = fn−1, n ≥ 1, f0 = 1 (f)(c) H~ (f) fn = 2 fn + 1, n ≥ 1, f0 = 0 8. ! (Be able to show a function solves a recurrence equation.) Show the function solves the recurrence equation. (a) Function: a(n) = 1, Recurrence equation: an = an−1. Answer: If a(n) = 1 then a(n − 1) = 1 and a(n) = a(n − 1). (b) Function: g(n) = n, Recurrence equation: gn = gn−1 + 1. Answer: If g(n) = n then g(n − 1) = n − 1 and g(n) = g(n − 1) + 1. (c) Function: t(n) = n(n − 1)/2, Recurrence equation: tn = tn−1 + (n − 1). Answer: If t(n) = n(n − 1)/2 then t(n − 1) = (n − 1)(n − 2)/2 and t(n) = t(n − 1) + (n − 1), that is (n − 1)(n − 2) (n − 1)(n − 2) 2(n − 1) + (n − 1) = + 2 2 2 (n − 1) = (n − 2 + 2) 2 n(n − 1) = 2 n (d) Function: m(n) = 2 − 1, Recurrence equation: mn = 2mn−1 + 1. Answer: If m(n) = 2n − 1 then m(n − 1) = 2n−1 − 1 and 2n − 1 = 2(2n−1 − 1) + 1. ~ 9. (Be able to determine a function that computes the partial sums of a sequence.) Let Sn = hs0, s1, s2,..., sn−1i be a list of length n. The sum function ∑ folds terms in list into their sum n−1 ~ sum(Sn) = ∑ sk = s0 + s1 + s2 + ··· + sn−1 k=0 (a) What is the function that computes the following sums? (All sums are from k = 0 to k = n − 1) i. sum(A~ n) = ∑ 1? Answer: The sum of the first n Alice numbers is n. ii. sum(G~ n) = ∑ k? Answer: The sum of the first n Gauss numbers is n(n − 1)/2. cse 1400 applied discrete mathematics sequences, induction & recursion 5 iii. sum(~Tn) = ∑ k(k − 1)/2? Answer: The sum of the first n Triangular numbers is n(n − 1)(n − 2)/6. k iv. sum(~2n) = ∑ 2 ? Answer: The sum of the first n powers of 2 is 2n − 1. k v. sum(10~ n) = ∑ 10 ? Answer: The sum of the first n powers of 10 is (10n − 1)/9. ~ vi. sum(Fn) = ∑ fk? Answer: The sum of the first n Fibonacci numbers is fn+1 − 1. (b) True or False: The sum function satisfies the recurrence equation ~ ~ sum(Sn) = sum(Sn−1) + sn−1 Explain your answer. Answer: True. Explanation: The sum of the first n terms of the sequence ~S is equal to the sum of the th first n − 1 terms of ~S plus sn, the n term. ~ 10. (Be able to determine a function that computes the partial products of a sequence.) Let Sn = hs0, s1, s2,..., sn−1i be a list of length n. The product function ∏ folds terms in the sequence into their product n−1 ~ prod(Sn) = ∏ sk = s0 · s1 · s2 ··· sn−1 k=0 (a) What is the function that computes the following products? (~ ) = n−1 i.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    34 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us