Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms II
Advertisements

Week 6 - Wednesday CS322.
Chapter 8 Recursion. 8.1 Recursively Defined Sequences.
Chapter Recurrence Relations
Introduction to Algorithms
Recursion Lecture 18: Nov 18.
Recursion Chapter 8. 2 Chapter Contents What Is Recursion? Tracing a Recursive Method Recursive Methods That Return a Value Recursively Processing an.
Chapter 10 Recursion. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Explain the underlying concepts of recursion.
Recursion.
© 2006 Pearson Addison-Wesley. All rights reserved3-1 Chapter 3 Recursion: The Mirrors.
1 Section 6.1 Recurrence Relations. 2 Recursive definition of a sequence Specify one or more initial terms Specify rule for obtaining subsequent terms.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 5. Recursive Algorithms.
COMPSCI 105 S Principles of Computer Science Recursion 3.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
CENG 7071 Recursion. CENG 7072 Recursion Recursion is a technique that solves a problem by solving a smaller problem of the same type. A recursive function.
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Analysis of Recursive Algorithms October 29, 2014
Copyright © Cengage Learning. All rights reserved.
Fall 2014 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Advanced Counting Techniques
Sequences Informally, a sequence is a set of elements written in a row. – This concept is represented in CS using one- dimensional arrays The goal of mathematics.
Week 6 - Monday CS322.
Fall 2015 COMP 2300 Discrete Structures for Computation
Department of Computer Science Data Structures Using C++ 2E Chapter 6: Recursion Learn about recursive Definitions Algorithms Functions Explore the base.
© 2006 Pearson Addison-Wesley. All rights reserved 3-1 Chapter 3 Recursion: The Mirrors.
Chapter 3 Recursion: The Mirrors. © 2004 Pearson Addison-Wesley. All rights reserved 3-2 Recursive Solutions Recursion –An extremely powerful problem-solving.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
13.2 Recursive Definitions Objective 1) Provide the recursive definition for sequences; 2) Identify the type of a sequence from a recursive definition.
Chapter 5: Sequences, Mathematical Induction, and Recursion 5.6 Defining Sequences Recursively 1 So, Nat’ralists observe, a Flea/Hath smaller Fleas on.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Lecture#16 Discrete Mathematics. Recursion Now, 1 is an odd positive integer by the definition base. With k = 1, = 3, so 3 is an odd positive integer.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
CSE 2813 Discrete Structures Recurrence Relations Section 6.1.
Chapter 8 Recursion Modified.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Chapter 4 Recursion. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter Objectives Explain the underlying concepts of recursion.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Chapter 8 With Question/Answer Animations. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
By: Lokman Chan Recursive Algorithm Recursion Definition: A function that is define in terms of itself. Goal: Reduce the solution to.
Recurrence Relation Models
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Chapter 6.1: Recurrence Relations Discrete Mathematical Structures: Theory and Applications.
Lecture - 8 On Stacks, Recursion. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Lecture Outline Quick sort Algorithm Recursion –Calculate n factorial –Fibonacci.
Discrete Mathematics Recurrence Relations Chapter 5 R. Johnsonbaugh
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Spring 2016 COMP 2300 Discrete Structures for Computation
Spring 2016 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University.
Discrete Mathematics Lecture # 22 Recursion.  First of all instead of giving the definition of Recursion we give you an example, you already know the.
7. RECURSIONS Rocky K. C. Chang October 12, 2015.
Spring 2016 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University.
1 CS1120: Recursion. 2 What is Recursion? A method is said to be recursive if the method definition contains a call to itself A recursive method is a.
Recursion Chapter 10 Carrano, Data Structures and Abstractions with Java, Second Edition, (c) 2007 Pearson Education, Inc. All rights reserved X.
Discrete Math For Computing II. Contact Information B. Prabhakaran Department of Computer Science University of Texas at Dallas Mail Station EC 31, PO.
Recursion.
Pramada Ramachandran, Assistant Professor, Department of Mathematics,
COMP108 Algorithmic Foundations Divide and Conquer
Introduction to Recurrence Relations
Recursive Thinking Chapter 9 introduces the technique of recursive programming. As you have seen, recursive programming involves spotting smaller occurrences.
Recursive Thinking Chapter 9 introduces the technique of recursive programming. As you have seen, recursive programming involves spotting smaller occurrences.
Copyright © Cengage Learning. All rights reserved.
CS1120: Recursion.
Copyright © Cengage Learning. All rights reserved.
Recursion: The Mirrors
1A Recursively Defined Functions
Recursion: The Mirrors
Presentation transcript:

Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 5.6 Defining Sequences Recursively

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Sequences Informally, A set of elements written in a row and demonstrate some pattern (i.e. 1, 3, 5, 7, 9) In the sequence denoted, each individual elements is called a term. in is called a subscript or index, is the subscript of the initial term, is the subscript of the final term. 2

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University How to Express a Sequence? Write the first few terms with the expectation that the general pattern will be obvious i.e. “consider the sequence 3, 5, 7, 9 …” Misunderstandings can occur Give an explicit formula for it th term, i.e. By recursion which requires a recurrence relation. 3 for all integers

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Recursion Recursion requires recurrence relation relates later terms in the sequence to earlier terms and initial conditions, values of the first few terms of the sequence. Ex. for all integers, (recurrence relation) (initial conditions) 4

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Formal Definition A recurrence relation for a sequence is a formula that relates each term to certain of its predecessors, where is an integer with. The initial condition for such a recurrence relation specify the values of if is a fixed integer, or, where is an integer with if depends on. 5

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Another Example Computing terms Recursive sequence, for all integers, find (recurrence relation) (initial conditions) 6

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Equivalent Recursion There is more than one way to setup a recursive sequence! for all Are the two sequences equivalent? show the results of the sequence for terms: starting at change first term to second by adjusting first for all start at 0 (k≥0) same as the second form. 7

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Example Show that sequence given satisfies a recurrence relation: for is equivalent to for General term of the sequence starting with, then for substitute for and 8

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Solving Recursive Problems To solve a problem recursively means to find a way to break it down into smaller subproblems each having the same form as the original problem. 9

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Towers of Hanoi Problem statement Eight disks with holes in the center that are stacked from largest diameter to smallest on the first of three poles. Move the stacked disk from one pole to another. Rules A larger disk cannot be placed on top of a smaller disk at any time. Watch this: h?v=aGlt2G-DC8c h?v=aGlt2G-DC8c 10

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Towers of Hanoi Recursive Solution 1.Transfer the top disks from pole to pole. (Note: requires a number of moves.) 2.Move the bottom disk from pole to pole. 3.Transfer the top disks from pole to pole. (Again, if, execution of this step will require more than one move.) 11

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Towers of Hanoi Suppose is the minimum number of moves to transfer n disks from one pole to another pole. Then, we know and 12

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Fibonacci 13 Leonardo of Pisa was the greatest mathematician of the 13th century. Proposed the following problem: A single pair of rabbits (male/female) is born at the beginning of a year. Assuming the following conditions: Rabbit pairs are not fertile during their first month of life but thereafter give birth to one new male/female pair at the end of every month. No rabbits die How many rabbits will there be at the end of the year?

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University 1 st month 2 nd month 3 rd month 4 th month 5 st month Non-fertile Fertile Fibonacci 14 To solve the problem you can hand compute for each of the 12 months.

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Fibonacci 15 To solve the problem you can hand compute for each of the 12 months. num of pairs alive at end of month k = num of pairs alive at end of month k -1 + num of pairs born at end of month k = num of pairs alive at month k -1 + num of pairs alive at month k -2

Fall 2015 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Why We Need Recursion in Computer Science 16 Give us a power to divide a big problem into smaller pieces Divide-and-Conquer technique (in Algorithm design) Recursive programming is a popular technique Generally, we can use other techniques such as multiple loops, but complicated to design and analyze Question Given that what is ?