This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Illinois Institute of Technology Department of Computer Science Lecture 2: January 26, 2009 CS 430 Introduction to Algorithms Spring Semester, 2009 1 Solving Recurrences 1.1 Fun with Fibonacci numbers Consider the reproductive cycle of bees. Each male bee has a mother but no father; each female bee has both a mother and a father. If we examine the generations we see the following family tree: We easily see that the number of ancestors in each generation is the sum of the two numbers before it. For example, our male bee has three greatgrandparents, two grandparents, and one parent, and 3 = 2 + 1. The number of ancestors a bee has in generation n is defined by the Fibonacci sequence; we can also see this by applying the rule of sum. As a second example, consider light entering two adjacent planes of glass: At any meeting surface (between the two panes of glass, or between the glass and air), the light may either reflect or continue straight through (refract). For example, here is the light bouncing seven times before it leaves the glass. CS 430Spring, 2009 2 Lecture 2: January 26, 2009 In general, how many different paths can the light take if we are told that it bounces n times before leaving the glass? The answer to the question (in case you havent guessed) rests with the Fibonacci sequence. We can divide the set of paths with n reflections into two subsets, depending on where the first reflection happens. Suppose the first bounce is on the boundary between the two panes. After the bounce, the light either leaves the class immediately (so n = 1), or bounces again off the top of the upper pane. After the second bounce, if any, the path is equivalent to a path that enters from the top and bounces n 2 times. Suppose the first bounce is not at the boundary between the two panes. Then either there are no bounces at all (so n = 0) or the first bounce is off the bottom pane. After the first bounce, the path is equivalent to a path that enters from the bottom and bounces n 1 times. Entering through the bottom pane is the same as entering through the top pane (but flipped over). Thus, we obtain the following recurrence relation for F n , the number of paths with exactly n bounces. There is exactly one way for the light to travel with no bouncesstraight throughand exactly two ways for the light to travel with only one bounceoff the bottom and off the middle. For any n > 1, there are F n 1 paths where the light bounces off the bottom of the glass, and F n 2 paths where the light bounces off the middle and then off the top....
View
Full
Document
 Spring '08
 KAPOOR
 Algorithms

Click to edit the document details