Ch离散数学英文实用.pptx
《Ch离散数学英文实用.pptx》由会员分享,可在线阅读,更多相关《Ch离散数学英文实用.pptx(44页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Recursively Defined FunctionsDefine a function f(n)recursively,n is an integer and n 0:Basis Step:Specify the value of the function at n=0(or a special value):f(0)Recursive Step:For n 0,specify a rule for producing the value of f(n+1)from f(n)Example:f(0)=3 f(n+1)=2f(n)+3f(3)=2f(2)+3=2(2f(1)+3)+3 =2
2、(2(f(0)+3)+3)+3=2(2(3+3)+3)+3=45第1页/共44页Recursive Function ExampleRecursive definition of factorial function f(n)=n!=n(n-1)(n-2)21 and f(0)=0!=1Basis:f(0)=1Recursive:f(n+1)=(n+1)f(n)f(5)=5f(4)=54f(3)=543f(2)=5432f(1)=54321f(0)=543211=120第2页/共44页Recursive Function ExampleGive a recursive definition o
3、f:Solution:The first part of the definition isThe second part is第3页/共44页Fibonacci Functionf(0)=0,f(1)=1,f(n)=f(n-1)+f(n-2)for n=2,3,4,.f(2)=f(1)+f(0)=1+0=1f(3)=f(2)+f(1)=1+1=2f(4)=f(3)+f(2)=2+1=3f(5)=f(4)+f(3)=3+2=5f(6)=f(5)+f(4)=5+3=8We denote Fibonacci numbers as fn=f(n),n=0,1,2,第4页/共44页Fibonacci
4、NumbersSuppose a newly-born pair of rabbits,one male,one female,are put in a field.Rabbits are able to mate at the age of one month so that at the end of its second month a female can produce another pair of rabbits.Suppose that our rabbits never die and that the female always produces one new pair(
5、one male,one female)every month f1=1f2=f1+f0=1+0=1f3=f2+f1=1+1=2f4=f3+f2=2+1=3f5=f4+f3=3+2=5f6=f5+f4=5+3=8第5页/共44页Fibonacci ExampleTheorem:When n 3,fn n-2,=(1+5)/2Proof by strong inductionBasis step:For n=3,f3=2 =(1+5)/2(5=2.236)For n=4,f4=3 2=(3+5)/2Why we need to prove n=3 and n=4?第6页/共44页Fibonacc
6、i ExampleInductive step:Assume fj j-2,for all j,3 j k,k 4.We must show that fk+1 k-1.Note that fk+1=fk+fk-1By induction assumption,fk k-2 and fk-1 k-3So,fk+1=fk+fk-1 k-2+k-3 We now only need to show that k-2+k-3=k-1 is a solution of x2 x 1=0,so 2=+1k-1=2 k-3=(+1)k-3=k-2+k-3第7页/共44页Recursively Define
7、d Infinite SetsBasis Step:Specify an initial collection of elements in the setRecursive Step:Provide rules for forming new elements in the set from those already known to be in the setExample:Basis Step:3 SRecursive Step:if x S and y S then x+y SThen,S=3,6,9,12,15,18,21,第8页/共44页Recursive Definition
8、of StringsSet of strings,denoted as *,over an alphabet or symbol set can be defined recursively byBasis:*(is the empty string)Recursive:if w *and x ,then wx *Example:=0,1.*contains the following:empty string 0,100,01,10,11000,001,010,011,100,101,110,111,第9页/共44页String ConcatenationDefinition:Two str
9、ings can be combined via the operation of concatenation(串联).Let be a set of symbols and*be the set of strings formed from the symbols in.We can define the concatenation of two strings,denoted by,as followsForanyw *,w =w,is the empty stringIfw1 *and w2 *,then the concatenation of w1and w2 is w1 w2 or
10、 just w1w2If w1=abra and w2=cadabra,the concatenation w1w2=abracadabra第10页/共44页Length of StringLength of a string is defined as the number of symbols in the stringRecursive definition of length of a stringBasis:l()=0Recursive:l(wx)=l(w)+1,w *and x Let be the English letters.Find the length of“math”:
11、l(math)=l(mat)+1=(l(ma)+1)+1=(l(m)+1)+1)+1=(l()+1)+1)+1)+1=(0+1)+3=4第11页/共44页Balanced Parentheses Example:Give a recursive definition of the set of balanced parentheses P Solution:Basis Step:()PRecursive Step:If w P,then ()w P,(w)P and w()P.Show that()()is in P.Why is)()not in P?第12页/共44页Well-Formed
12、 Formulas(合适公式)ExampleWell-Formed Formulas for compound propositions include T,F,propositional variables and operators(,)Recursive definition of well-formed formulas:Basis:T,F and any propositional variable x are well-formed formulasRecursive:if A and B are well-formed formulas,then A,A B,A B,A B an
13、d A B are also well-formed formulas第13页/共44页Well-Formed Formulas ExampleExamples.Are the following well-formed formulas?(From definition,start with the variable of single-operand operator)1.(A (B)(C)(D)2.(A B)C)3.(A (B)(D)4.(A B)C第14页/共44页T1T2T3T4T5T1T2T2T2T2T1T1Full Binary Tree(满二叉树)ExampleBasis St
14、ep:any single node is a binary treeInductive Step:If T1 and T2 are full binary trees,then the following tree T is also a full binary tree:pick a new root node and attach it to the root of T1 as a left subtree and to the root of T2 as a right subtree(T1 and T2 can be the same).Denoted T=T1T2So,what i
15、s a full binary tree?第15页/共44页Basis:the empty set is an extended binary treeInductive:If T1 and T2 are extended binary trees,then the following tree T is also an extended binary tree:pick a new root node and attach it to the root of T1 as a left subtree and to the root of T2 as a right subtree(T1 an
16、d T2 can be the same).Denoted T=T1T2Extended Binary Tree ExampleT0T1T2T3T4T1T1T1T0T1T0T0T5T6T7T8T9T13T0第16页/共44页Structural InductionApplying Structural Induction for recursively defined setsBasis Step:Show that the result is true for all elements specified in the basis step of the recursive definiti
17、onRecursive(or inductive)Step:Show that,if the result is true for the old elements used in constructing new elements,then it is also true for the new elements第17页/共44页Induction ExampleShow that the set S recursively defined as“3 S and if x S and y S then x+y S”,is the set of all positive integers th
18、at are multiples of 3Proof:let A be the set of all positive integers that are multiples of 3,A=3n|n=1,2,.We need to prove A S and S A,which proves S=AA S:(Simple Induction on n)when n=1,3 S.Assume when n=k,3k S.For n=k+1,we need to show that 3(k+1)S.3(k+1)=3k+3,by induction assumption 3k S.Also from
19、 induction basis,3 S.By recursive definition of S(let x=3k and y=3),3(k+1)=3k+3 S第18页/共44页Structural Induction ExampleProof(continued):S A:(Structural Induction)we need to show that any element in S is a multiple of 3(A)Basis step:3 is in S and 3 is a multiple of 3Recursive step:assume the elements(
20、x and y)used to build new elements are true(multiples of 3).Show that the newly built elements(x+y)is also true(multiple of 3).We know by previous knowledge that if 3|x and 3|y,then 3|(x+y).So,x+y A第19页/共44页Structural Induction ExampleUse structural induction to show that l(xy)=l(x)+l(y)l(w)=length
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Ch 离散数学 英文 实用
限制150内