Discrete Mathematics - PowerPoint PPT Presentation

About This Presentation
Title:

Discrete Mathematics

Description:

Title: Chap3 Mathematical Reasoning , Induction, and Recursion Author: Ellen Last modified by: Created Date: 2/3/2005 1:42:38 AM Document presentation format – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 36
Provided by: Elle1160
Category:

less

Transcript and Presenter's Notes

Title: Discrete Mathematics


1
Discrete Mathematics
  • Chapter 4 ??(Induction)???(Recursion)

???? ????? ???
2
4.1 ?????
  • ??????????

??1. ????????????2. ???????????,???????????? ?
????????????????
3
(No Transcript)
4
P(n) ??????? (?? n ? 2n)
?????????? P(n) ??????n??? ????????
1. ????(Basis) ??P(1)??
(?n??1?????) (? n ? 0 ????
P(0)??,??????n??????) 2. ????(Inductive)
???k???????,?P(k)???P(k1)???
(???n??k?????, ?????,????n??k1???
??)
  • ?? ???????????????????,????
    ????.

5
Example 1 ???n?????, .
  • Proof.
  • (Basis) n1? ??
  • (Inductive) ??nk?????,
  • ?
  • ?nk1?,
  • ?? 12k(k1)

  • ??,???????

6
  • Example 2. ????????n???????n2.
  • ??????????????
  • Pf
  • Basis n1? 1 12 ??
  • Inductive ??nk?????,?
  • 135(2k-1) k2
  • ?nk1?,?? 135(2k-1)(2k1)
  • k2
    2k1 (k1)2 ??
  • ???????????

7
  • Example 5. ???????????????n,??? n lt 2n ????
  • pf
  • Basis n1?,1 lt 21 ??.
  • Inductive
  • ??nk ?????,? k lt 2k.
  • ? nk1?
  • ?? k 1
  • lt 2k 1
  • ? 2k 1 ??
  • ? k 1 lt 2k 1 ???
  • ???????????

8
Exercise 4.1
3. ???n???????,
  • 7. ???n? ?0 ????,

9
(??)
Example 7. The harmonic numbers Hk, k 1,2,3,,
are
defined by . Use
MI to show that
whenever n is a nonnegative integer.
Pf Let P(n) be the proposition that
. Basis step P(0) is true,
since .
Inductive step Assume that P(k) is true for
some k, i.e.,
Consider P(k1)
10
(??)
?P(k1) is true. By MI, P(n) is true for all
n?Z.
Exercise 7, 13
11
4.2 Strong Induction(??????)
(??)
  • Basis step ??
  • Inductive step Assume all the statements
    P(1), P(2), , P(k) are true.
    Show that P(k1) is
    also true.

12
(??)
Example 2. ??? n? gt1???,? n ?????????? Pf ?
P(n) ?? n ????????? ????. Basis P(2)
is true, ?? 2 ??? Inductive ?? P(2),
P(3), , P(k) ??true. ?? P(k 1)
Case 1 k 1 is prime ?
P(k1) is true Case 2 k 1
is composite,
i.e., k 1 ab where 2 ? a ? b lt k1
????????, a ? b??????????.
? k 1??????? ? P(k1)
is true. ??????????.
Note ??????????????
13
(??)
Example 4. Prove that every amount of postage of
12 cents or more can be formed using just 4-cent
and 5-cent stamps. Pf Let P(n) be the statement
that the postage of n cents can
formed using just 4-cent and 5-cent stamps.
Basis P(12) is true, since 12 4 ? 3
P(13) is true, since 13 4 ? 2 5
? 1 P(14) is true, since 14
4 ? 1 5 ? 2 P(15) is
true, since 15 5 ? 3 Inductive Assume
P(12), P(13), , P(k) are true.
Consider P(k1) Suppose k-3
4 ? m 5 ? n.
Then k1 4 ? (m1) 5 ? n.
? P(k1) is true. By Strong MI, P(n)
is true if n?Z and n ?12.
(k-3 ? 12)
Exercise 7
14
4.3 ????.
  • Def. ???????????????????recursion(??).
  • ? ???????? 1, 2, 4, 8, 16, 32, 64, ?
  • (1) ???????,???
  • an2n, n0,1,2,
  • (2) ???????,???
  • ??? a01,
  • ??? an12an,
    n0, 1, 2,

15
Example 1. ???? f ?????????
f(0)3, f(n1) 2f(n)3
?? f(1), f(2), f(3), f(4).
Sol f(1) 2f(0) 3 9
f(2) 2f(1) 3 21 f(3) 2f(2) 3
45 f(4) 2f(3) 3 93
16
Example 2. ?????? F(n) n! ??????
  • Sol
  • ??? F(0) 1
  • ??? ? F(n1) (n1)!, F(n) n!
    ? F(n1) F(n) ? (n1)

Def1, Example 5. ???(Fibonacci numbers) f0, f1,
f2, ???? ??? f0 0, f1 1,
??? fn fn-1
fn-2, for n 2,3,4, What is f5
? Sol f2 f1 f0 1
f3 f2 f1 2 f4 f3 f2 3
f5 f4 f3 5
17
Exercise 4.3
  • 1. ?? f(0)1 ???????? f(n) (n 0, 1, 2, ),
    ?? f(1), f(2), f(3), f(4)? (b) f(n1)
    3f(n) (d) f(n1) f(n)2 f(n) 1

3. ?? f(0) -1,f(1) 2 ???????? f(n) (n 0,
1, 2, ),?? f(2), f(3), f(4), f(5)? (a)
f(n1) f(n) 3f(n-1)
8. ????an (n 1, 2, 3, ) ?????,? (a) an
4n - 2 (c) an n (n - 1)
18
Example 6. Show that fn gt a n-2 , where
(??)
Pf ( By Strong MI ) Let P(n) be the
statement fn gta n-2 . Basis f3 2 gt a

so that P(3) and
P(4) are true. Inductive Assume that
P(3), P(4), , P(n) are true. We
must show that P(n1) is true.
fn1 fn fn-1 gt a n-2 a n-3
a n-3(a 1)
? a 1 a 2
? fn1 gt a n-3 ? a 2 a n-1
We get that P(n1) is true. By Strong
MI , P(n) is true for all n ? 3
19
(??)
  • ?Recursively defined sets.
  • Example 7. Let S be defined recursively by
  • 3?S
  • xy?S if x?S
    and y?S.
  • Show that S is the of positive integers
    divisible by 3
  • (i.e., S 3,
    6, 9, 12, 15, 18,
  • Pf
  • Let A be the set of all positive integers
    divisible by 3.
  • We need to prove that AS.
  • (i) A ? S (By MI)
  • Let P(n) be the statement that
    3n?S

  • (ii) S ? A (??S???)
  • (1) 3 ? A ,
  • (2) if x?A,y?A, then 3x and 3y.
  • ? 3(xy) ?
    xy?A
  • ?S ? A

S A
20
Definition 2. The set of strings over an
alphabet?? is denoted by ?. The empty
string is denoted by l, l ??, and wx??
whenever w?? and x??.eg. ? a, b, c
? l, a , b , c , aa , ab , ac , ba , bb ,
bc, abcabccba,
(??)
la
lb
lc
  • Example 9. Give a recursive definition of
    ?l(w), the length of the string
    w??
  • Sol
  • initial value l(l)0
  • recursive def l(wx)l(w)1 if
    w??, x??.

21
(??)
  • Exercise 13, 48, 49
  • Exercise 39. When does a string belong to the
    set A of bit strings defined recursively by
  • l?A
  • 0x1?A if x?A.
  • Sol
  • Al, 01 , 0011, 000111,
  • ??bit string a 0000111 ?
  • a?A

22
(??)
  • Ackermanns function
  • A(m, n) 2n
    if m 0
  • 0
    if m ? 1 and n 0
  • 2
    if m ? 1 and n 1
  • A(m-1, A(m, n-1)) if
    m ? 1 and n ? 2
  • Exercise 49 Show that A(m,2)4 whenever m ? 1
  • Pf
  • A(m,2) A(m-1, A(m,1)) A(m-1,2) whenever
    m ? 1.
  • A(m,2) A(m-1,2) A(m-2,2) A(0,2)
    4.

23
4.4 ?????
  • ? ??,????????????????,??? ??????????
  • ?. gcd(a, b) gcd(b mod a, a) (when
    a lt b) ?????b mod a 0,???gcd?
  • Def 1. ??????????????????????????,????????

24
Example 1. ???? n!??????, ?? n?
????.
Sol n! ????? ??? 0! 1
??? n! n ? (n-1)!.
???4! ? 4! 4?3!,
3! 3?2!,
2! 2?1!,
1! 1?0!,
???? 1! 1,
0! 1,
2! 2,
3! 6,
4! 24
25
Algorithm 1. Procedure factorial(n
nonnegative integer) if n 0 then
factorial(n)1 else factorial(n) n ?
factorial(n-1)
??????
?????
Algorithm 1. Procedure factorial(n
nonnegative integer) if n 0 then
return(1) else return(n ? factorial(n-1))
26
?Algorithm 1??4!???
factorial(4) 4 ? factorial(3)
4 ? 6 24
3 ? factorial(2)
3 ? 2 6
2 ? factorial(1)
2 ? 1 2
1 ? factorial(0) 1 ? 11
Algorithm 1. Procedure factorial(n
nonnegative integer) if n 0 then
factorial(n)1 else factorial(n) n ?
factorial(n-1)
27
Example 2. ???? an,??????, ?? a???,n??????
Sol an?????
??? a01 ??? an a ? an-1.
28
Exercise 4.4
  • ?? ?????2???,?a2, n4???,
    ??????24??????

Algorithm 2. Procedure power(a number, n
nonnegative integer) if n 0 then
power(a, n)1 else power(a, n) a ?
power(a, n-1).
29
Example 4. ??? gcd(a,b) ??????,?? altb.
  • Sol

???gcd(a,b) gcd(b mod a, a)
???gcd(0,b) b
Algorithm 4. procedure gcd(a,b nonnegative
integers with altb) if a0 then gcd(a,b) b
else gcd(a,b) gcd(b mod a, a).
30
Exercise 4.4
  • 6. ?????4???,??gcd(8, 13)???

Algorithm 4. procedure gcd(a,b nonnegative
integers with altb) if a0 then gcd(a,b) b
else gcd(a,b) gcd(b mod a, a).
29. ????????????????n?,?? a01,a12,?an
an-1? an-2,n2, 3, ?
31
(??)
Example 5. Search x in a1, a2,,an by Linear
Search
Sol
Alg. 5 procedure search (i, j, x integers)
if ai x then location i else if i
j then location 0 else search(i1,
j, x)
call search(1, n, x)
32
Example 6. Search x from a1,a2,,an by binary
search (recursive version).
(??)
search x from ai, ai1, , aj
  • Sol

Alg. 5 procedure binary_search (x , i , j
integers) m ?(ij) / 2? if x am
then location m else if (x lt am and i lt
m) then binary_search(x, i, m-1)
else if (x gt am and j gt m) then
binary_search(x, m1, j)
else location 0
call binary_search(x, 1, n)
33
Example 1. Give the value of n!, n?Z
(??)
Sol
Note n! n ? (n-1)!
Alg. 1 (Recursive Procedure) procedure
factorial (n positive integer) if n 1 then
factorial (n) 1 else factorial (n) n ?
factorial (n-1)
Alg. (Iterative Procedure) procedure
iterative_factorial (n positive integer) x
1 for i 1 to n x i ? x
x n!
34
? iterative alg. ???????? recursive alg.?
(??)
  • ? Find Fibonacci numbers
  • (Note f00, f11, fnfn-1fn-2 for n?2)

Alg. 7 (Recursive Fibonacci) procedure
Fibonacci (n nonnegative integer) if n 0
then Fibonacci (0) 0 else if n 1 then
Fibonacci (1) 1 else Fibonacci (n)
Fibonacci (n-1)Fibonacci (n-2)
35
(??)
Alg.8 (Iterative Fibonacci) procedure
iterative_fibonacci (n nonnegative integer)
if n 0 then y 0 // y f0 else begin
x 0 y 1
// y f1 for i 1 to n-1
begin z x y
x y
y z end end y
is fn
i 1 i 2 i 3
z f2 f3 f4
x f1 f2 f3
y f2 f3 f4
Exercise 11, 35
Write a Comment
User Comments (0)
About PowerShow.com