Chapter 8: Recursion. March 10, 2008

Size: px
Start display at page:

Download "Chapter 8: Recursion. March 10, 2008"

Transcription

1 Chapter 8: Recursion March 10, 2008

2 Outline Recursively Defined Sequences Solving Recurrence Relations by Iteration General Recursive Definitions

3 Recursively Defined Sequences As mentioned in 4.1, a sequence can be defined using recursion. This means that the k-th terms is defined using an equation involving previous terms in the sequence. For example, a k = a k 1 + 2a k 2, k 2 and a 0 = 1, a 1 = 2 The values for a 0 and a 1 in this example are called the initial values of the sequence. The formula a k = a k 1 + 2a k 2, k 2 which relates the k-th term to some of its predecessors is called the recurrence relation for this sequence.

4 Example For the recursively defined sequence with initial conditions a k = a k 1 + 2a k 2, k 2 a 0 = 1, a 1 = 2 compute the terms a 2, a 3, and a 4. Solution: a 2 = a 1 + 2a 0 = 2 + 2( 1) = 0 a 3 = a 2 + 2a 1 = = 4 a 4 = a 3 + 2a 2 = = 4

5 Example Show that the sequence satisfies the recurrence relation 0, 1, 5, 19,..., 3 n 2 n,... d k = 5d k 1 6d k 2, k 2 Solution: Substitute d k 1 = 3 k 1 2 k 1 d k 2 = 3 k 2 2 k 2 into the recurrence relation:

6 d k = 5 (3 k 1 2 k 1 ) 6 (3 k 2 2 k 2 ) = 5 3 k k k k 2 = 5 3 k k k k 1 = 3 3 k k 1 = 3 k 2 k

7 Basic Problem of Recursion Given a recursively defined sequence a n, find an analytical formula a n = f (n) for the sequence. In general, this may be a difficult problem. In this course, we will look at relatively simple instances of recursively defined sequences. Our approach will generally consist of the following two steps: 1 Guess an explicit formula for a n = f (n). [Often, this consists of writing out the first several terms and trying to discover a pattern.] 2 Prove that this formula is correct using induction.

8 Example: The Tower of Hanoi In 1883., Edouard Lucas invented a mathematical puzzle, which he called The Tower of Hanoi. The set-up of the puzzle consisted of 8 disks of different sizes placed in decreasing size on top of one another on one pole in a row of three poles. The task is to transfer these disks from the pole where they lie originally to one of the others, never placing a larger disk on top of a smaller one. Figure: The Tower of Hanoi

9 In 1884., De Parville described it in a more colourful way, after slightly changing the statement of the original puzzle: On the steps of the altar in the temple of Benares, for many, many years Brahmins have been moving a tower of sixty-four golden disks from one pole to another, one by one, never placing a larger on top of a smaller. When all disks have been transferred, the Tower and the Brahmins will fall, and it will be the end of the world. Assuming this legend is true, is there anything to worry about?

10 Suppose that the poles are labelled as A, B, and C. We will approach this problem in a general way and assume that, at the beginning, we have k disks piled on the pole A. What is the most efficient way of transferring these k disks from A to C? In other words, what is the minimum number of steps (moves) m k that are necessary in order to move the disks from A to C? Notice first, that in order to transfer the largest disk from A to C, we first have to move the k 1 smaller disks lying above it from A to B, in order to get them out of the way.

11 The most efficient algorithm for transferring all the disks from A to C will then require these three stages: 1 Transfer the top k 1 disks from A to B, using C for intermediate moves, until all these disks end up piled on B. 2 Move the largest (bottom) disk from A to C. 3 Finally, move those remaining k 1 disks from B to C, using A (which is now empty) to help us with intermediate moves.

12 Suppose m n is the minimum number of steps necessary to move n disks from one pole to another. Then m k = m k m k 1 = 2m k and, of course, m 1 = 1. Therefore, the number of steps required to move k disks from one pole to another is an example of a recursively defined sequence.

13 The first few terms of this sequence are m 1 = 1 m 2 = 2m = 3 m 3 = 2m = 7 m 4 = 2m = 15 m 5 = 2m = 31 m 6 = 2m = 63

14 In 8.2, we will see that the formula for the k-th term is: m k = 2 k 1 So, for k = 64 disks, the minimum number of moves necessary to transfer all the disks is m 64 = Even if the Brahmins were able to transfer the disks very quickly, with one move taking one second, it would take around 584 billion years to finish the task!

15 Example: Fibonacci Numbers In 1202, an Italian mathematician Leonardo di Pisa (also known as Fibonacci) posed the following problem: A single pair of rabbits (male and female) is born at the beginning of a year. Suppose the following is true: 1 Rabbit pairs are not fertile during the first month of their life, but thereafter give birth to one new male/female pair at the end of every month. 2 No rabbits die. How many rabbits will there be at the end of the first year?

16 Question: If we know the number of rabbit pairs at the ends of previous months, how can we calculate the number of rabbit pairs at the end of the k-th month? Observation: The number of pairs born at the end of the k-th month is the number of pairs alive at the end of the (k 2)-th month (they are the pairs that will be fertile at the beginning of the k-th month). But, the number of rabbit pairs alive at the end of the k-th month is the sum of the pairs that were alive at the end of the (k 1)-th month and those pairs that were born at the end of the k-th month. Therefore, the number of pairs alive at the end of the month k is the number of pairs alive at the end of the month k 1 plus the number of pairs that were alive at the end of the month k 2.

17 If we denote the number of pairs alive at the end of the n-th month F n, we have the recurrence relation with the initial conditions F k = F k 1 + F k 2 F 0 = 1, F 1 = 1 [F 1 = 1, since the original pair does not procreate during the first month.] Then, F 2 = F 1 + F 0 = 2 F 3 = F 2 + F 1 = 3. F 11 = F 10 + F 9 = 144 F 12 = F 11 + F 10 = 233 So, after one year, there will be 233 rabbit pairs.

18 It can be shown (which will be too complicated for this course) that the general formula for F n is: ( F n = ) n+1 ( ) n

19 Example: Interest Compounded Several Times A Year When an annual interest rate of i is compounded m times a year, the interest rate paid per period is i/m. For example, if the annual interest rate is 3% = 0.03 is compounded quarterly, the interest rate paid per quarter is 0.03/4 = Let P k represent the amount on the deposit at the end of the k-th compounding period, for k 1, and P 0 being the original deposit into the account.

20 The interest earned during the k-th period is ( ) i P k 1 m The amount in the account at the end of the k-th period will be ( ) ( i P k = P k 1 + P k 1 = P k i ) m m

21 Suppose $ 10,000 is deposited at 3% compounded quarterly. (a) How much will the account be worth at the end of one year, assuming no further deposits have been made? (b) The annual percentage rate (APR) is the percentage increase in the value of an account over one year. What is the APR for this account?

22 Solution: (a) The recurrence relation is ( P k = P k i ) = P k 1 m with the initial condition P 0 = $10, 000. P 1 = $10, 000 = $10, P 2 = $10, = $10, P 3 = $10, = $10, P 4 = $10, = $10, The amount in the account after one year will be $10, (b) The APR will be = = 3.034%

23 Method of Iteration Iteration is the most basic method for findingan explicit formula for a sequence defined recursively. Suppose we are given a sequence a 0, a 1, a 2,... defined by some recurrence relation and initial conditions. We start from the initial conditions and compute successive terms of the sequence until we discover a pattern.

24 Example Let a 0, a 1, a 2,... be the sequence defined recursively in the following way: for all integers k 1 a k = a k a 0 = 1 Use iteration to guess an explicit formula for the sequence. Solution: a 0 = 1 a 1 = a = a 2 = a = (1 + 2) + 2 = a 3 = a = ( ) + 2 = a 4 = a = ( ) + 2 = A good guess would be that a n = 1 + n 2 = 1 + 2n

25 Definition A sequence a 0, a 1, a 2,... is called an arithmetic sequence if, and only if, there is a constant d such that a k = a k 1 + d, for k 1 Equivalently, a n = a 0 + n d, n 0.

26 Example Let r be a nonzero constant, and suppose a sequence a 0, a 1, a 2,... is defined recursively as a k = ra k 1, k 1 a 0 = a Use iteration to guess an explicit formula for this sequence. Solution: a 0 = a Guess: a n = r n a for n 0 a 1 = ra 0 = ra a 2 = ra 1 = r(ra) = r 2 a a 3 = ra 2 = r(r 2 a) = r 3 a a 4 = ra 3 = r(r 3 a) = r 4 a.

27 Definition A sequence a 0, a 1, a 2,... is called a geometric sequence if, and only if, there is a constant r 0 such that a k = ra k 1, k 1 Equivalently, a n = a 0 r n, n 0

28 In previous examples, we were able to guess an explicit formula for a recursively defined sequence using iteration. At this point, a formula is just a mere guess; in order to be able to convince ourselves that it indeed describes the recursively defined sequence, we need to prove it. To prove that a guessed formula is correct, we generally use mathematical induction (either weak or strong, depending on the problem)

29 Example In 8.1, we saw that The Tower of Hanoi problem leads to the following recursively defined sequence: m k = 2m k 1 + 1, k 2 m 1 = 1 Let s try to find an explicit formula for m n. Solution: First, we ll guess a formula using iteration: m 1 = 1 m 2 = 2m = = m 3 = 2m = 2 (2 + 1) + 1 = m 4 = 2m = 2 ( ) + 1 =

30 It seems that the formula for m n will be m n = 2 n n Using the formula for the sum of the geometric sequence with r = 2, we get m n = 2n = 2n 1 Next, we ll try to confirm this conjecture using induction: When n = 1, we see that: m 1 = = 1 which is true. Suppose the formula is true for some n = k 1: m k = 2 k 1

31 Finally, let s prove that the formula is also true for n = k + 1: m k+1 = 2m k + 1 (by definition) = 2(2 k 1) + 1 (by ind. hypothesis) = 2 k = 2 k+1 1 which finishes our proof that m n = 2 n 1

32 Example Consider the following recursively defined sequence: b k = b 0 = 1 b k b k 1, k 1 Guess an explicit formula for b n and then use induction to prove it. Solution: b 0 = 1 b 1 = b b 0 = 1 2 b 2 = b b 1 = 1 3 b 3 = b b 2 = 1 4.

33 Guess: b n = 1 n+1, n 0. Now, let s try to prove the conjecture by induction: Obviously, b 0 = = 1 Suppose that the formula is true for some n = k 1: Then, for n = k + 1: b k b k = 1 k + 1 b k+1 = (by definition) 1 + b k 1/(k + 1) = (ind.hypothesis) 1 + 1/(k + 1) = 1 k + 2

34 Recursively Defined Sets One way to define a set is to do it recursively. This means that we specify a few core objects that belong to the set and give some rules which show how to build new ( more complex ) set elements from old ( simpler ) ones.

35 A recursive definition of a set consists of the following components: 1 BASE: A statement that certain objects belong to the set. 2 RECURSION: A collection of rules specifying how to form new objects from those which are known to already belong to the set. 3 RESTRICTION: A statement that no objects belong to the set other than those coming from (1) or (2).

36 Example Recursive Definition of Boolean Expressions Boolean expressions were introduced in Chapter 1 as statements in propositional logic which are built from the alphabet p, q, r,..., logical symbols,, and, along with parentheses (, and ). 1 BASE: Each symbol of the alphabet is a Boolean expression. 2 RECURSION: If P and Q are Boolean expressions, then so are (a) (P Q), (b) (P Q), (c) P 3 RESTRICTION: There are no Boolean expressions over the alphabet other than those obtained from (1) and (2).

37 Derive the fact that is a Boolean expression. Solution: ((p q) ((p s) r)) 1 By (1), p, q, r, and s are Boolean expressions. 2 By (2b), (2c) and Step 1, (p q), and s are Boolean expressions. 3 By (2a) and Step 2, (p s) is a Boolean expression. 4 By (2a) and Step 3, ((p s) r) is a Boolean expression. 5 By (2c) and Step 4, ((p s) r) is a Boolean expression. 6 By (2b) and Step 5, ((p q) ((p s) r)) is a Boolean expression.

38 Example Set of Strings over an Alphabet Let S be the set of all strings over the alphabet {a, b}. S can be defined recursively in the following way: 1 BASE: The empty string ɛ is in S. 2 RECURSION: If s S, then (a) sa S, (b) sb S where sa and sb are strings obtained by appending the letters a and b to the string s (This is also called the concatenation of s with a or b) 3 RESTRICTION: Nothing is in S other than strings defined in (1) and (2).

39 Derive the fact that baa S. Solution: 1 By (1), ɛ S. 2 By Step 1 and (2b), b = ɛb S 3 By Step 2 and (2a), ba S 4 By Step 3 and (2a), baa S.

40 Example Parenthesis Structures Some configurations of parentheses in algebraic expressions are legal [e.g. (( )( )), and (( ))( )] while others are not [e.g. ( )) or ((( ))( )] A recursive definition of the set P of legal configurations of parenthesis can be given as follows: 1 BASE: ( ) is in P. 2 RECURSION: (a) If E is in P, so is (E). (b) If E and F are in P, so is EF. 3 RESTRICTION: No configurations of parentheses are in P, other than those derived from (1) and (2) above.

41 Derive the fact that ( )(( )) is in P. Solution: 1 By (1), ( ) is in P. 2 By (2a) and Step 1, (( )) is in P. 3 By (2b) and Steps 1 and 2, ( )(( )) is in P.

42 Proving Properties of Recursively Defined Sets Structural Induction for Recursively Defined Sets Suppose S is a set that has been defined recursively, and consider a property that objects in S may or may not possess. To prove that every object in S has this property: 1 Show that each object in the BASE for S has the property. 2 Show that for each rule in RECURSION, if the rule is applied to an object in S that has the property, then the object constructed by the rule also satisfies the property. Since the only objects in S are those obtained through BASE and RECURSION, then every object in S has the asserted property.

43 Example If P is the set of all legal configurations of parentheses from the previous example, prove that every configuration in P contains an equal number of left and right parentheses. Solution: We will use structural induction to prove this property. BASE: The only object in the base is ( ), for which the property is true. RECURSION: Suppose that all previously constructed configurations of parentheses have the same number of left and right parenthesis.

44 If we use the rule (2a) to construct a new object, then it is of the form (E), where E is a previously constructed configuration. By inductive hypothesis, E contains the same number of left and right parentheses, so the same will be true of (E). If we use the rule (2b) to get a new configuration, then it is of the form EF, where E and F are two previously constructed configurations. By inductive hypothesis, both E and F have the equal number of left and right parentheses, so the same must be true of EF. So, using structural induction, we were able to prove that every configuration from P has an equal number of left and right parentheses.

45 Example Give a recursive definition for the set of all strings over the alphabet {0, 1} for which all the 0 s precede all the 1 s. Solution: 1 BASE: The empty string ɛ is in S. 2 RECURSION: If s is a string in S, then so are (a) 0s, (b) s1 3 RESTRICTION: There are no strings in S except those coming from (1) and (2).

Chapter 5: Sequences, Mathematic Induction, and Recursion

Chapter 5: Sequences, Mathematic Induction, and Recursion Chapter 5: Sequences, Mathematic Induction, and Recursion Hao Zheng Department of Computer Science and Engineering University of South Florida Tampa, FL 33620 Email: zheng@cse.usf.edu Phone: (813)974-4757

More information

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Alessandro Artale UniBZ - http://www.inf.unibz.it/ artale/ SECTION 5.6 Defining Sequences Recursively Copyright Cengage Learning. All rights reserved.

More information

1 Sequences and Summation

1 Sequences and Summation 1 Sequences and Summation A sequence is a function whose domain is either all the integers between two given integers or all the integers greater than or equal to a given integer. For example, a m, a m+1,...,

More information

Recurrence Relations and Recursion: MATH 180

Recurrence Relations and Recursion: MATH 180 Recurrence Relations and Recursion: MATH 180 1: Recursively Defined Sequences Example 1: The sequence a 1,a 2,a 3,... can be defined recursively as follows: (1) For all integers k 2, a k = a k 1 + 1 (2)

More information

5. Sequences & Recursion

5. Sequences & Recursion 5. Sequences & Recursion Terence Sim 1 / 42 A mathematician, like a painter or poet, is a maker of patterns. Reading Sections 5.1 5.4, 5.6 5.8 of Epp. Section 2.10 of Campbell. Godfrey Harold Hardy, 1877

More information

Every subset of {1, 2,...,n 1} can be extended to a subset of {1, 2, 3,...,n} by either adding or not adding the element n.

Every subset of {1, 2,...,n 1} can be extended to a subset of {1, 2, 3,...,n} by either adding or not adding the element n. 11 Recurrences A recurrence equation or recurrence counts things using recursion. 11.1 Recurrence Equations We start with an example. Example 11.1. Find a recurrence for S(n), the number of subsets of

More information

Advanced Counting Techniques. Chapter 8

Advanced Counting Techniques. Chapter 8 Advanced Counting Techniques Chapter 8 Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence Relations Nonhomogeneous Recurrence Relations Divide-and-Conquer

More information

Page references correspond to locations of Extra Examples icons in the textbook.

Page references correspond to locations of Extra Examples icons in the textbook. Rosen, Discrete Mathematics and Its Applications, 7th edition Extra Examples Section 8. Recurrence Relations Page references correspond to locations of Extra Examples icons in the textbook. p.50, icon

More information

12 Sequences and Recurrences

12 Sequences and Recurrences 12 Sequences and Recurrences A sequence is just what you think it is. It is often given by a formula known as a recurrence equation. 12.1 Arithmetic and Geometric Progressions An arithmetic progression

More information

Recurrence Relations

Recurrence Relations Recurrence Relations Recurrence Relations Reading (Epp s textbook) 5.6 5.8 1 Recurrence Relations A recurrence relation for a sequence aa 0, aa 1, aa 2, ({a n }) is a formula that relates each term a k

More information

Part III, Sequences and Series CS131 Mathematics for Computer Scientists II Note 16 RECURRENCES

Part III, Sequences and Series CS131 Mathematics for Computer Scientists II Note 16 RECURRENCES CS131 Part III, Sequences and Series CS131 Mathematics for Computer Scientists II Note 16 RECURRENCES A recurrence is a rule which defines each term of a sequence using the preceding terms. The Fibonacci

More information

Learning Objectives

Learning Objectives Learning Objectives Learn about recurrence relations Learn the relationship between sequences and recurrence relations Explore how to solve recurrence relations by iteration Learn about linear homogeneous

More information

Advanced Counting Techniques. 7.1 Recurrence Relations

Advanced Counting Techniques. 7.1 Recurrence Relations Chapter 7 Advanced Counting Techniques 71 Recurrence Relations We have seen that a recursive definition of a sequence specifies one or more initial terms and a rule for determining subsequent terms from

More information

Discrete Structures Lecture Sequences and Summations

Discrete Structures Lecture Sequences and Summations Introduction Good morning. In this section we study sequences. A sequence is an ordered list of elements. Sequences are important to computing because of the iterative nature of computer programs. The

More information

Section Summary. Sequences. Recurrence Relations. Summations. Examples: Geometric Progression, Arithmetic Progression. Example: Fibonacci Sequence

Section Summary. Sequences. Recurrence Relations. Summations. Examples: Geometric Progression, Arithmetic Progression. Example: Fibonacci Sequence Section 2.4 Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations Introduction Sequences are ordered lists of elements.

More information

Advanced Counting Techniques

Advanced Counting Techniques . All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education. Advanced Counting

More information

Definition: A sequence is a function from a subset of the integers (usually either the set

Definition: A sequence is a function from a subset of the integers (usually either the set Math 3336 Section 2.4 Sequences and Summations Sequences Geometric Progression Arithmetic Progression Recurrence Relation Fibonacci Sequence Summations Definition: A sequence is a function from a subset

More information

Chapter12. Relations, Functions, and Induction

Chapter12. Relations, Functions, and Induction . Relations. Functions. Seuences.4 Mathematical Induction.5 Recurrence Relations Chapter Review Chapter Relations, Functions, and Induction In this chapter we introduce the concepts of a relation and a

More information

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee Algorithm Analysis Recurrence Relation Chung-Ang University, Jaesung Lee Recursion 2 Recursion 3 Recursion in Real-world Fibonacci sequence = + Initial conditions: = 0 and = 1. = + = + = + 0, 1, 1, 2,

More information

Section Summary. Sequences. Recurrence Relations. Summations Special Integer Sequences (optional)

Section Summary. Sequences. Recurrence Relations. Summations Special Integer Sequences (optional) Section 2.4 Section Summary Sequences. o Examples: Geometric Progression, Arithmetic Progression Recurrence Relations o Example: Fibonacci Sequence Summations Special Integer Sequences (optional) Sequences

More information

Recursion and Induction

Recursion and Induction Recursion and Induction Themes Recursion Recurrence Definitions Recursive Relations Induction (prove properties of recursive programs and objects defined recursively) Examples Tower of Hanoi Gray Codes

More information

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska LECTURE 1 INTRODUCTION Course Web Page www.cs.stonybrook.edu/ cse547 The webpage contains: detailed lectures notes slides; very detailed

More information

6.042/18.062J Mathematics for Computer Science March 17, 2005 Srini Devadas and Eric Lehman. Recurrences

6.042/18.062J Mathematics for Computer Science March 17, 2005 Srini Devadas and Eric Lehman. Recurrences 6.04/8.06J Mathematics for Computer Science March 7, 00 Srini Devadas and Eric Lehman Lecture Notes Recurrences Recursion breaking an object down into smaller objects of the same type is a major theme

More information

Recursion: Introduction and Correctness

Recursion: Introduction and Correctness Recursion: Introduction and Correctness CSE21 Winter 2017, Day 7 (B00), Day 4-5 (A00) January 25, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Today s Plan From last time: intersecting sorted lists and

More information

Lecture 8 : Structural Induction DRAFT

Lecture 8 : Structural Induction DRAFT CS/Math 240: Introduction to Discrete Mathematics 2/15/2011 Lecture 8 : Structural Induction Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last week we discussed proofs by induction. We

More information

Sec$on Summary. Sequences. Recurrence Relations. Summations. Ex: Geometric Progression, Arithmetic Progression. Ex: Fibonacci Sequence

Sec$on Summary. Sequences. Recurrence Relations. Summations. Ex: Geometric Progression, Arithmetic Progression. Ex: Fibonacci Sequence Section 2.4 Sec$on Summary Sequences Ex: Geometric Progression, Arithmetic Progression Recurrence Relations Ex: Fibonacci Sequence Summations 2 Introduc$on Sequences are ordered lists of elements. 1, 2,

More information

1 Sequences and Series

1 Sequences and Series Sequences and Series. Introduction What is a sequence? What is a series? Very simply a sequence is an infinite list of things. Normally we consider now only lists of numbers - so thus, the list of all

More information

Generalization of Fibonacci sequence

Generalization of Fibonacci sequence Generalization of Fibonacci sequence Etienne Durand Julien Chartrand Maxime Bolduc February 18th 2013 Abstract After studying the fibonacci sequence, we found three interesting theorems. The first theorem

More information

SOLVING LINEAR RECURRENCE RELATIONS

SOLVING LINEAR RECURRENCE RELATIONS SOLVING LINEAR RECURRENCE RELATIONS Schaum's outline Sec. 6.6 6.9 Rosen Sec. 8.1 8. November 9, 017 margarita.spitsakova@ttu.ee ICY0001: Lecture 8 November 9, 017 1 / 47 Contents 1 Motivation examples

More information

Ex. Here's another one. We want to prove that the sum of the cubes of the first n natural numbers is. n = n 2 (n+1) 2 /4.

Ex. Here's another one. We want to prove that the sum of the cubes of the first n natural numbers is. n = n 2 (n+1) 2 /4. Lecture One type of mathematical proof that goes everywhere is mathematical induction (tb 147). Induction is essentially used to show something is true for all iterations, i, of a sequence, where i N.

More information

Chapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms

Chapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms 1 Chapter Summary Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms 2 Section 5.1 3 Section Summary Mathematical Induction Examples of

More information

Recurrence Relations

Recurrence Relations Recurrence Relations Winter 2017 Recurrence Relations Recurrence Relations A recurrence relation for the sequence {a n } is an equation that expresses a n in terms of one or more of the previous terms

More information

1 Recursive Algorithms

1 Recursive Algorithms 400 lecture note #8 [ 5.6-5.8] Recurrence Relations 1 Recursive Algorithms A recursive algorithm is an algorithm which invokes itself. A recursive algorithm looks at a problem backward -- the solution

More information

Binomial Coefficient Identities/Complements

Binomial Coefficient Identities/Complements Binomial Coefficient Identities/Complements CSE21 Fall 2017, Day 4 Oct 6, 2017 https://sites.google.com/a/eng.ucsd.edu/cse21-fall-2017-miles-jones/ permutation P(n,r) = n(n-1) (n-2) (n-r+1) = Terminology

More information

Discrete Mathematics -- Chapter 10: Recurrence Relations

Discrete Mathematics -- Chapter 10: Recurrence Relations Discrete Mathematics -- Chapter 10: Recurrence Relations Hung-Yu Kao ( 高宏宇 ) Department of Computer Science and Information Engineering, National Cheng Kung University First glance at recurrence F n+2

More information

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction Math 4 Summer 01 Elementary Number Theory Notes on Mathematical Induction Principle of Mathematical Induction Recall the following axiom for the set of integers. Well-Ordering Axiom for the Integers If

More information

The Fibonacci Sequence

The Fibonacci Sequence Elvis Numbers Elvis the Elf skips up a flight of numbered stairs, starting at step 1 and going up one or two steps with each leap Along with an illustrious name, Elvis parents have endowed him with an

More information

Reductions, Recursion and Divide and Conquer

Reductions, Recursion and Divide and Conquer Chapter 5 Reductions, Recursion and Divide and Conquer CS 473: Fundamental Algorithms, Fall 2011 September 13, 2011 5.1 Reductions and Recursion 5.1.0.1 Reduction Reducing problem A to problem B: (A) Algorithm

More information

Induction and Recursion

Induction and Recursion . All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education. Induction and Recursion

More information

At the start of the term, we saw the following formula for computing the sum of the first n integers:

At the start of the term, we saw the following formula for computing the sum of the first n integers: Chapter 11 Induction This chapter covers mathematical induction. 11.1 Introduction to induction At the start of the term, we saw the following formula for computing the sum of the first n integers: Claim

More information

Math Circle: Recursion and Induction

Math Circle: Recursion and Induction Math Circle: Recursion and Induction Prof. Wickerhauser 1 Recursion What can we compute, using only simple formulas and rules that everyone can understand? 1. Let us use N to denote the set of counting

More information

Recurrent Problems. ITT9131 Konkreetne Matemaatika. Chapter One The Tower of Hanoi Lines in the Plane The Josephus Problem

Recurrent Problems. ITT9131 Konkreetne Matemaatika. Chapter One The Tower of Hanoi Lines in the Plane The Josephus Problem Recurrent Problems ITT93 Konkreetne Matemaatika Chapter One The Tower of Hanoi Lines in the Plane The Josephus Problem Contents The Tower of Hanoi Lines in the Plane 3 The Josephus Problem 4 Intermezzo:

More information

MATH 324 Summer 2011 Elementary Number Theory. Notes on Mathematical Induction. Recall the following axiom for the set of integers.

MATH 324 Summer 2011 Elementary Number Theory. Notes on Mathematical Induction. Recall the following axiom for the set of integers. MATH 4 Summer 011 Elementary Number Theory Notes on Mathematical Induction Principle of Mathematical Induction Recall the following axiom for the set of integers. Well-Ordering Axiom for the Integers If

More information

3.1 Induction: An informal introduction

3.1 Induction: An informal introduction Chapter 3 Induction and Recursion 3.1 Induction: An informal introduction This section is intended as a somewhat informal introduction to The Principle of Mathematical Induction (PMI): a theorem that establishes

More information

Section Summary. Sequences. Recurrence Relations. Summations. Examples: Geometric Progression, Arithmetic Progression. Example: Fibonacci Sequence

Section Summary. Sequences. Recurrence Relations. Summations. Examples: Geometric Progression, Arithmetic Progression. Example: Fibonacci Sequence Section 2.4 1 Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations 2 Introduction Sequences are ordered lists of

More information

With Question/Answer Animations

With Question/Answer Animations Chapter 5 With Question/Answer Animations Copyright McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill Education. Chapter Summary

More information

Unit 5: Sequences, Series, and Patterns

Unit 5: Sequences, Series, and Patterns Unit 5: Sequences, Series, and Patterns Section 1: Sequences and Series 1. Sequence: an ordered list of numerical terms 2. Finite Sequence: has a first term (a beginning) and a last term (an end) 3. Infinite

More information

CHAPTER 4 SOME METHODS OF PROOF

CHAPTER 4 SOME METHODS OF PROOF CHAPTER 4 SOME METHODS OF PROOF In all sciences, general theories usually arise from a number of observations. In the experimental sciences, the validity of the theories can only be tested by carefully

More information

COMP 555 Bioalgorithms. Fall Lecture 3: Algorithms and Complexity

COMP 555 Bioalgorithms. Fall Lecture 3: Algorithms and Complexity COMP 555 Bioalgorithms Fall 2014 Lecture 3: Algorithms and Complexity Study Chapter 2.1-2.8 Topics Algorithms Correctness Complexity Some algorithm design strategies Exhaustive Greedy Recursion Asymptotic

More information

Sequences and Series. College Algebra

Sequences and Series. College Algebra Sequences and Series College Algebra Sequences A sequence is a function whose domain is the set of positive integers. A finite sequence is a sequence whose domain consists of only the first n positive

More information

Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University

Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University U Kang 1 In This Lecture Set concepts and notation Logarithms Summations Recurrence Relations Recursion Induction Proofs

More information

Induction and recursion. Chapter 5

Induction and recursion. Chapter 5 Induction and recursion Chapter 5 Chapter Summary Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms Mathematical Induction Section 5.1

More information

CSCE 222 Discrete Structures for Computing. Dr. Hyunyoung Lee

CSCE 222 Discrete Structures for Computing. Dr. Hyunyoung Lee CSCE 222 Discrete Structures for Computing Sequences and Summations Dr. Hyunyoung Lee Based on slides by Andreas Klappenecker 1 Sequences 2 Sequences A sequence is a function from a subset of the set of

More information

Another Proof By Contradiction: 2 is Irrational

Another Proof By Contradiction: 2 is Irrational Another Proof By Contradiction: 2 is Irrational Theorem: 2 is irrational. Proof: By contradiction. Suppose 2 is rational. Then 2 = a/b for some a, b N +. We can assume that a/b is in lowest terms. Therefore,

More information

Lecture 12 : Recurrences DRAFT

Lecture 12 : Recurrences DRAFT CS/Math 240: Introduction to Discrete Mathematics 3/1/2011 Lecture 12 : Recurrences Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last few classes we talked about program correctness. We

More information

Mathematical Induction

Mathematical Induction Mathematical Induction MAT30 Discrete Mathematics Fall 018 MAT30 (Discrete Math) Mathematical Induction Fall 018 1 / 19 Outline 1 Mathematical Induction Strong Mathematical Induction MAT30 (Discrete Math)

More information

Sequences and Summations ICS 6D. Prof. Sandy Irani

Sequences and Summations ICS 6D. Prof. Sandy Irani Sequences and Summations ICS 6D Prof. Sandy Irani Test Poll What is your favorite flavor of ice cream? A) Vanilla B) Chocolate C) Moose Tracks D) Mint Chocolate Chip E) None of the above Sequences A sequence

More information

Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University

Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University U Kang 1 In This Lecture Set Concepts and Notation Relation Logarithm and Summations Recurrence Relations Recursion

More information

Linear Recurrence Relations

Linear Recurrence Relations Linear Recurrence Relations Linear Homogeneous Recurrence Relations The Towers of Hanoi According to legend, there is a temple in Hanoi with three posts and 64 gold disks of different sizes. Each disk

More information

Cpt S 223. School of EECS, WSU

Cpt S 223. School of EECS, WSU Math Review 1 Why do we need math in a data structures course? To nalyze data structures and algorithms Deriving formulae for time and memory requirements Will the solution scale? Quantify the results

More information

The Principle of Linearity applications in the areas of algebra and analysis

The Principle of Linearity applications in the areas of algebra and analysis Proseminar Mathematisches Problemlösen University of Karlsruhe SS 6 The Principle of Linearity applications in the areas of algebra and analysis Franziska Häfner Contents Converting complex problems into

More information

Discrete Mathematics

Discrete Mathematics Discrete Mathematics I- MCA / III- CS & IS LECTURE NOTES (B. E OF VTU) VTU-EDUSAT Programme-17 Dr. V. Lokesha Professor of Mathematics DEPARTMENT OF MATHEMATICS ACHARYA INSTITUTE OF TECNOLOGY Soldevanahalli,

More information

4.1 Induction: An informal introduction

4.1 Induction: An informal introduction Chapter 4 Induction and Recursion 4.1 Induction: An informal introduction This section is intended as a somewhat informal introduction to The Principle of Mathematical Induction (PMI): a theorem that establishes

More information

Reading 5 : Induction

Reading 5 : Induction CS/Math 40: Introduction to Discrete Mathematics Fall 015 Instructors: Beck Hasti and Gautam Prakriya Reading 5 : Induction In the last reading we began discussing proofs. We mentioned some proof paradigms

More information

Chapter 2. Mathematical Reasoning. 2.1 Mathematical Models

Chapter 2. Mathematical Reasoning. 2.1 Mathematical Models Contents Mathematical Reasoning 3.1 Mathematical Models........................... 3. Mathematical Proof............................ 4..1 Structure of Proofs........................ 4.. Direct Method..........................

More information

Why do we need math in a data structures course?

Why do we need math in a data structures course? Math Review 1 Why do we need math in a data structures course? To nalyze data structures and algorithms Deriving formulae for time and memory requirements Will the solution scale? Quantify the results

More information

CSC2100B Data Structures Analysis

CSC2100B Data Structures Analysis CSC2100B Data Structures Analysis Irwin King king@cse.cuhk.edu.hk http://www.cse.cuhk.edu.hk/~king Department of Computer Science & Engineering The Chinese University of Hong Kong Algorithm An algorithm

More information

Decrypting Fibonacci and Lucas Sequences. Contents

Decrypting Fibonacci and Lucas Sequences. Contents Contents Abstract Introduction 3 Chapter 1 U(n) Formula in 3 unknowns 7 Chapter Polynomial Expression of L(kn) in Terms of L(n) 19 Introduction of the Tables (Fibonacci Table, Lucas-Fibonacci Table and

More information

CS 2210 Discrete Structures Advanced Counting. Fall 2017 Sukumar Ghosh

CS 2210 Discrete Structures Advanced Counting. Fall 2017 Sukumar Ghosh CS 2210 Discrete Structures Advanced Counting Fall 2017 Sukumar Ghosh Compound Interest A person deposits $10,000 in a savings account that yields 10% interest annually. How much will be there in the account

More information

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa CS:4330 Theory of Computation Spring 2018 Regular Languages Finite Automata and Regular Expressions Haniel Barbosa Readings for this lecture Chapter 1 of [Sipser 1996], 3rd edition. Sections 1.1 and 1.3.

More information

Chapter 13 - Inverse Functions

Chapter 13 - Inverse Functions Chapter 13 - Inverse Functions In the second part of this book on Calculus, we shall be devoting our study to another type of function, the exponential function and its close relative the Sine function.

More information

Notes on generating functions in automata theory

Notes on generating functions in automata theory Notes on generating functions in automata theory Benjamin Steinberg December 5, 2009 Contents Introduction: Calculus can count 2 Formal power series 5 3 Rational power series 9 3. Rational power series

More information

MATH 402 : 2017 page 1 of 6

MATH 402 : 2017 page 1 of 6 ADMINISTRATION What? Math 40: Enumerative Combinatorics Who? Me: Professor Greg Smith You: students interested in combinatorics When and Where? lectures: slot 00 office hours: Tuesdays at :30 6:30 and

More information

CVO103: Programming Languages. Lecture 2 Inductive Definitions (2)

CVO103: Programming Languages. Lecture 2 Inductive Definitions (2) CVO103: Programming Languages Lecture 2 Inductive Definitions (2) Hakjoo Oh 2018 Spring Hakjoo Oh CVO103 2018 Spring, Lecture 2 March 13, 2018 1 / 20 Contents More examples of inductive definitions natural

More information

Example. How to Guess What to Prove

Example. How to Guess What to Prove How to Guess What to Prove Example Sometimes formulating P (n) is straightforward; sometimes it s not. This is what to do: Compute the result in some specific cases Conjecture a generalization based on

More information

3515ICT: Theory of Computation. Regular languages

3515ICT: Theory of Computation. Regular languages 3515ICT: Theory of Computation Regular languages Notation and concepts concerning alphabets, strings and languages, and identification of languages with problems (H, 1.5). Regular expressions (H, 3.1,

More information

Nondeterministic finite automata

Nondeterministic finite automata Lecture 3 Nondeterministic finite automata This lecture is focused on the nondeterministic finite automata (NFA) model and its relationship to the DFA model. Nondeterminism is an important concept in the

More information

Jong C. Park Computer Science Division, KAIST

Jong C. Park Computer Science Division, KAIST Jong C. Park Computer Science Division, KAIST Today s Topics Introduction Solving Recurrence Relations Discrete Mathematics, 2008 2 Computer Science Division, KAIST Definition A recurrence relation for

More information

What can you prove by induction?

What can you prove by induction? MEI CONFERENCE 013 What can you prove by induction? Martyn Parker M.J.Parker@keele.ac.uk Contents Contents iii 1 Splitting Coins.................................................. 1 Convex Polygons................................................

More information

Structural Induction

Structural Induction Structural Induction In this lecture we ll extend the applicability of induction to many universes, ones where we can define certain kinds of objects by induction, in addition to proving their properties

More information

When is a number Fibonacci?

When is a number Fibonacci? When is a number Fibonacci? Phillip James Department of Computer Science, Swansea University March 6, 009 Abstract This article looks into the importance of the Fibonacci numbers within Computer Science,

More information

Recursion and Induction

Recursion and Induction Recursion and Induction Themes Recursion Recursive Definitions Recurrence Relations Induction (prove properties of recursive programs and objects defined recursively) Examples Tower of Hanoi Gray Codes

More information

Intermediate Math Circles March 11, 2009 Sequences and Series

Intermediate Math Circles March 11, 2009 Sequences and Series 1 University of Waterloo Faculty of Mathematics Centre for Education in Mathematics and Computing Intermediate Math Circles March 11, 009 Sequences and Series Tower of Hanoi The Tower of Hanoi is a game

More information

CHAPTER 8 Advanced Counting Techniques

CHAPTER 8 Advanced Counting Techniques 96 Chapter 8 Advanced Counting Techniques CHAPTER 8 Advanced Counting Techniques SECTION 8. Applications of Recurrence Relations 2. a) A permutation of a set with n elements consists of a choice of a first

More information

Algoritmi di Bioinformatica. Computational efficiency I

Algoritmi di Bioinformatica. Computational efficiency I Algoritmi di Bioinformatica Zsuzsanna Lipták Laurea Magistrale Bioinformatica e Biotechnologie Mediche (LM9) a.a. 2014/15, spring term Computational efficiency I 2 / 18 Computational Efficiency As we will

More information

(Ordinary) mathematical induction is a way to prove things about natural numbers. We can write it as a rule: φ(0) x. φ(x) φ(succ(x)) x.

(Ordinary) mathematical induction is a way to prove things about natural numbers. We can write it as a rule: φ(0) x. φ(x) φ(succ(x)) x. 1 Ordinary Induction (Ordinary) mathematical induction is a way to prove things about natural numbers. We can write it as a rule: φ(0) x. φ(x) φ(succ(x)) x. φ(x) where φ(x) is a statement involving a number

More information

The Fibonacci Sequence

The Fibonacci Sequence The Fibonacci Sequence MATH 100 Survey of Mathematical Ideas J. Robert Buchanan Department of Mathematics Summer 2018 The Fibonacci Sequence In 1202 Leonardo of Pisa (a.k.a Fibonacci) wrote a problem in

More information

The associativity of equivalence and the Towers of Hanoi problem

The associativity of equivalence and the Towers of Hanoi problem Information Processing Letters 77 (2001) 71 76 The associativity of equivalence and the Towers of Hanoi problem Roland Backhouse a,, Maarten Fokkinga b a School of Computer Science and IT, University of

More information

CSI Mathematical Induction. Many statements assert that a property of the form P(n) is true for all integers n.

CSI Mathematical Induction. Many statements assert that a property of the form P(n) is true for all integers n. CSI 2101- Mathematical Induction Many statements assert that a property of the form P(n) is true for all integers n. Examples: For every positive integer n: n! n n Every set with n elements, has 2 n Subsets.

More information

Chapter 8. Sequences, Series, and Probability. Selected Applications

Chapter 8. Sequences, Series, and Probability. Selected Applications Chapter 8 Sequences, Series, and Probability 8. Sequences and Series 8.2 Arithmetic Sequences and Partial Sums 8.3 Geometric Sequences and Series 8.4 Mathematical Induction 8.5 The Binomial Theorem 8.6

More information

Fibonacci Numbers. November 7, Fibonacci's Task: Figure out how many pairs of rabbits there will be at the end of one year, following rules.

Fibonacci Numbers. November 7, Fibonacci's Task: Figure out how many pairs of rabbits there will be at the end of one year, following rules. Fibonacci Numbers November 7, 2010 Fibonacci's Task: Figure out how many pairs of rabbits there will be at the end of one year, following rules. Rules: 1. Start with a pair of new rabbits, born in December.

More information

Sum of Squares. Defining Functions. Closed-Form Expression for SQ(n)

Sum of Squares. Defining Functions. Closed-Form Expression for SQ(n) CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 22: Induction Overview Recursion A programming strategy that solves a problem by reducing it to simpler

More information

Fibonacci Numbers. By: Sara Miller Advisor: Dr. Mihai Caragiu

Fibonacci Numbers. By: Sara Miller Advisor: Dr. Mihai Caragiu Fibonacci Numbers By: Sara Miller Advisor: Dr. Mihai Caragiu Abstract We will investigate various ways of proving identities involving Fibonacci Numbers, such as, induction, linear algebra (matrices),

More information

MI 4 Mathematical Induction Name. Mathematical Induction

MI 4 Mathematical Induction Name. Mathematical Induction Mathematical Induction It turns out that the most efficient solution to the Towers of Hanoi problem with n disks takes n 1 moves. If this isn t the formula you determined, make sure to check your data

More information

Arithmetic Series Can you add the first 100 counting numbers in less than 30 seconds? Begin How did he do it so quickly? It is said that he

Arithmetic Series Can you add the first 100 counting numbers in less than 30 seconds? Begin How did he do it so quickly? It is said that he Little Freddie is said to have done the work in his head and written only the answer on his slate in less than 30 seconds. Can you do it in less than 30 seconds? Arithmetic Series An arithmetic series

More information

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 1

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 1 CS 70 Discrete Mathematics and Probability Theory Fall 013 Vazirani Note 1 Induction Induction is a basic, powerful and widely used proof technique. It is one of the most common techniques for analyzing

More information

Limits and Continuity

Limits and Continuity Chapter Limits and Continuity. Limits of Sequences.. The Concept of Limit and Its Properties A sequence { } is an ordered infinite list x,x,...,,... The n-th term of the sequence is, and n is the index

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 10:

CMSC 132, Object-Oriented Programming II Summer Lecture 10: CMSC 132, Object-Oriented Programming II Summer 2016 Lecturer: Anwar Mamat Lecture 10: Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 10.1 RECURSION

More information

{ 0! = 1 n! = n(n 1)!, n 1. n! =

{ 0! = 1 n! = n(n 1)!, n 1. n! = Summations Question? What is the sum of the first 100 positive integers? Counting Question? In how many ways may the first three horses in a 10 horse race finish? Multiplication Principle: If an event

More information

CS632 Notes on Relational Query Languages I

CS632 Notes on Relational Query Languages I CS632 Notes on Relational Query Languages I A. Demers 6 Feb 2003 1 Introduction Here we define relations, and introduce our notational conventions, which are taken almost directly from [AD93]. We begin

More information