DS_Lecture_22.pdf - Lecture 22 Recursive Definitions and Structural Induction Dr Chengjiang Long Computer Vision Researcher at Kitware Inc Adjunct

DS_Lecture_22.pdf - Lecture 22 Recursive Definitions and...

This preview shows page 1 - 10 out of 30 pages.

Lecture 22: Recursive Definitions and Structural Induction Dr. Chengjiang Long Computer Vision Researcher at Kitware Inc. Adjunct Professor at SUNY at Albany. Email: [email protected]
Image of page 1

Subscribe to view the full document.

C. Long Lecture 22 October 26, 2018 2 ICEN/ICSI210 Discrete Structures Outline Recursive Definitions Structural Induction
Image of page 2
C. Long Lecture 22 October 26, 2018 3 ICEN/ICSI210 Discrete Structures Outline Recursive Definitions Structural Induction
Image of page 3

Subscribe to view the full document.

C. Long Lecture 22 October 26, 2018 4 ICEN/ICSI210 Discrete Structures Example The sequence is defined by the following algorithm: 1. At the first step there are two numbers: 1, 1. 2. At the next step, insert between two numbers a new number which is the sum of two neighbors: 1, 2, 1 1, 3, 2, 3, 1 1, 4, 3, 5, 2, 5, 3, 4, 1 The sum of the sequence was defined: recursively S (0) = 2, S ( n +1) = 3 S ( n ) − 2 , explicitly S ( n ) = 3 n + 1 .
Image of page 4
C. Long Lecture 22 October 26, 2018 5 ICEN/ICSI210 Discrete Structures Recursive vs. Explicit Recursive Definition : in some cases is the only possible, reflects the algorithm, easier to read when programed, needs stack (risk of stack overflow) Explicit Definition: faster more reliable hard to read Why Recursive Definition is also called Inductive Definition? Is the sequence in the previous example defined recursively or explicitly? Can the sequence be defined explicitly? Recursion is useful to define sequences, functions, sets, and algorithms.
Image of page 5

Subscribe to view the full document.

C. Long Lecture 22 October 26, 2018 6 ICEN/ICSI210 Discrete Structures Recursive or Inductive Function Definition Basis Step: Specify the value of the function for the base case. Recursive Step: Give a rule for finding the value of a function from its values at smaller integers greater than the base case.
Image of page 6
C. Long Lecture 22 October 26, 2018 7 ICEN/ICSI210 Discrete Structures Inductive Definitions We completely understand the function f(n) = n! right? n! = 1 · 2 · 3 · … · (n-1) · n, n ³ 1 Inductive (Recursive) Definition But equivalently, we could define it like this: n ! = n × ( n - 1)!, if n > 1 1, if n = 1 ì í î Recursive Case Base Case
Image of page 7

Subscribe to view the full document.

C. Long Lecture 22 October 26, 2018 8 ICEN/ICSI210 Discrete Structures Inductive Definitions The 2 nd most common example: Fibonacci Numbers Recursive Case Base Cases ï î ï í ì > - + - = = = 1 if ) 2 ( ) 1 ( 1 if 1 0 if 0 ) ( n n f n f n n n f Is there a non-recursive definition for the Fibonacci Numbers? f ( n ) = 1 5 1 + 5 2 æ è ç ö ø ÷ n - 1 - 5 2 æ è ç ö ø ÷ n é ë ê ê ù û ú ú (Prove by induction.) All linear recursions have a closed form. Note why you need two base cases.
Image of page 8
C. Long Lecture 22 October 26, 2018 9 ICEN/ICSI210 Discrete Structures Recursively Defined Sets: Inductive Definitions Examples so far have been inductively defined functions. Sets can be defined inductively, too. Recursive Case Base Case Give an inductive definition of T = {x: x is a positive integer divisible by 3} 3 Î S x,y Î S ® x + y Î S Exclusion Rule: No other numbers are in S .
Image of page 9

Subscribe to view the full document.

Image of page 10
  • Spring '14
  • IASHVILI,I

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes