1 / 11

이산수학 (Discrete Mathematics) 3.4 재귀 호출 (Recursion)

이산수학 (Discrete Mathematics) 3.4 재귀 호출 (Recursion). 2006 년 봄학기 문양세 강원대학교 컴퓨터과학과. Recursive Definitions ( 재귀의 정의 ). 3.4 Recursion.

ssheckler
Download Presentation

이산수학 (Discrete Mathematics) 3.4 재귀 호출 (Recursion)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 이산수학 (Discrete Mathematics) 3.4 재귀 호출 (Recursion) 2006년 봄학기 문양세 강원대학교 컴퓨터과학과

  2. Recursive Definitions (재귀의 정의) 3.4 Recursion In induction, we prove all members of an infinite set have some property P by proving the truth for larger members in terms of that of smaller members.(귀납적 정의에서는, “무한 집합의 모든 멤버가 어떠한 성질 P를 가짐”을 보이기 위하여, “작은 멤버들을 사용하여 큰 멤버들이 참(P의 성질을 가짐)임”을 증명하는 방법을 사용하였다.) In recursive definitions, we similarly define a function, a predicate or a set over an infinite number of elements by defining the function or predicate value or set-membership of larger elements in terms of that of smaller ones.(재귀적 정의에서는, “작은 멤버들에 함수/술어/집합을 적용(정의)하여 모든 멤버들을 정의”하는 방법을 사용한다.)

  3. Recursion (재귀) 3.4 Recursion Recursion is a general term for the practice of defining an object in terms of itself (or of part of itself).(재귀란 객체를 정의하는데 있어서 해당 객체 자신을 사용하는 것을 의미한다.) An inductive proof establishes the truth of P(n+1) recursively in terms of P(n).(귀납적 증명은 P(n+1)이 참임을 증명하기 위하여 재귀적으로 P(n)을 사용하는 것으로 해석할 수 있다.) There are also recursive algorithms, definitions, functions, sequences, and sets.

  4. Recursively Defined Functions 3.4 Recursion • Simplest case: One way to define a function f:NS (for any set S) or series an=f(n) is to: • Define f(0). • For n>0, define f(n) in terms of f(0),…,f(n−1). • E.g.: Define the series an :≡2n recursively: • Let a0 :≡1. • For n>0, let an:≡2an-1.

  5. Another Example 3.4 Recursion • Suppose we define f(n) for all nN recursively by: • Let f(0)=3 • For all nN, letf(n+1)=2f(n)+3 • What are the values of the following? • f(1)= f(2)= f(3)= f(4)= 9 21 45 93

  6. Recursive Definition of Factorial 3.4 Recursion • Give an inductive definition of the factorial function F(n) :≡n! :≡ 23…n. • Base case: F(0) :≡ 1 • Recursive part: F(n) :≡n  F(n-1). • F(1)=1 • F(2)=2 • F(3)=6

  7. The Fibonacci Series 3.4 Recursion The Fibonacci seriesfn≥0 is a famous series defined by:f0 :≡ 0, f1 :≡ 1, fn≥2 :≡ fn−1 + fn−2 0 1 1 2 3 5 8 13

  8. Inductive Proof about Fibonacci Series 3.4 Recursion • Theorem: fn < 2n. • Proof: By induction. • Base cases: f0 = 0 < 20 = 1f1 = 1 < 21 = 2 • Inductive step: Use 2nd principle of induction (strong induction). Assume k<n, fk < 2k. Then fn = fn−1 + fn−2 is < 2n−1 + 2n−2 < 2n−1 + 2n−1 = 2n. 

  9. Recursively Defined Sets 3.4 Recursion • An infinite set S may be defined recursively, by giving: • A small finite set of base elements of S. (유한 개수의 기본 원소를 제시) • A rule for constructing new elements of S from previously-established elements. (새로운 원소를 만드는 방법을 제시) • Example: Let 3S, and let x+yS if x,yS. What is S? (= {3, 6, 9, 12, 15, …})

  10. The Set of All Strings 3.4 Recursion • Given an alphabet , the set * of all strings over  can be recursively defined as:  *( :≡ “”, the empty string) w * x   → wx  *

  11. Useful Information 3.4 Recursion I will not handle “structural induction,” and thus, you may skip pp. 258-268 in the text book.

More Related