{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Chapter8

# Chapter8 - Chapter 8 Recursion Outline 1 8.1 Recursively...

This preview shows pages 1–11. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 8: Recursion March 10, 2008 Outline 1 8.1 Recursively Defined Sequences 2 8.2 Solving Recurrence Relations by Iteration 3 8.4 General Recursive Definitions 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 + 2 a k- 2 , k ≥ 2 and a =- 1 , a 1 = 2 • The values for a and a 1 in this example are called the initial values of the sequence. • The formula a k = a k- 1 + 2 a k- 2 , k ≥ 2 which relates the k-th term to some of its predecessors is called the recurrence relation for this sequence. Example For the recursively defined sequence a k = a k- 1 + 2 a k- 2 , k ≥ 2 with initial conditions a =- 1 , a 1 = 2 compute the terms a 2 , a 3 , and a 4 . Solution: a 2 = a 1 + 2 a = 2 + 2 (- 1 ) = a 3 = a 2 + 2 a 1 = + 2 · 2 = 4 a 4 = a 3 + 2 a 2 = 4 + 2 · = 4 Example Show that the sequence , 1 , 5 , 19 , . . . , 3 n- 2 n , . . . satisfies the recurrence relation d k = 5 d k- 1- 6 d 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: d k = 5 · ( 3 k- 1- 2 k- 1 )- 6 · ( 3 k- 2- 2 k- 2 ) = 5 · 3 k- 1- 5 · 2 k- 1- 6 · 3 k- 2 + 6 · 2 k- 2 = 5 · 3 k- 1- 5 · 2 k- 1- 2 · 3 k- 1 + 3 · 2 k- 1 = 3 · 3 k- 1- 2 · 2 k- 1 = 3 k- 2 k 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. 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 • 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? 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...
View Full Document

{[ snackBarMessage ]}

### Page1 / 45

Chapter8 - Chapter 8 Recursion Outline 1 8.1 Recursively...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online