Professional Documents
Culture Documents
MAD101 Chap4
MAD101 Chap4
MAD101 Chap4
Department of Mathematics
The FPT university
Topics covered:
Topics covered:
Topics covered:
Topics covered:
Topics covered:
Topics covered:
Proof by Induction:
Proof by Induction:
Proof by Induction:
Proof by Induction:
Proof by Induction:
Proof by Induction:
F0 = 0, F1 = 1,
F0 = 0, F1 = 1, and
F0 = 0, F1 = 1, and
Fn = Fn−1 + Fn−2 for n = 2, 3, . . ..
F0 = 0, F1 = 1, and
Fn = Fn−1 + Fn−2 for n = 2, 3, . . ..
F0 = 0, F1 = 1, and
Fn = Fn−1 + Fn−2 for n = 2, 3, . . ..
(a) xn = 7 ∗ 5n+1
(a) xn = 7 ∗ 5n+1
(b) xn = n!
(a) xn = 7 ∗ 5n+1
(b) xn = n!
(c) xn = (−1)n
(a) xn = 7 ∗ 5n+1
(b) xn = n!
(c) xn = (−1)n
(d) xn = 2n − 6
(a) xn = 7 ∗ 5n+1
(b) xn = n!
(c) xn = (−1)n
(d) xn = 2n − 6
Basic step: 3 ∈ S
Basic step: 3 ∈ S
Recursive step: If x, y ∈ S then x + y ∈ S
Basic step: 3 ∈ S
Recursive step: If x, y ∈ S then x + y ∈ S
Example 2.
Basic step: 3 ∈ S
Recursive step: If x, y ∈ S then x + y ∈ S
Example 2.
(a) Give a recursive definition for the set of positive integers that are not
divisible by 3
Basic step: 3 ∈ S
Recursive step: If x, y ∈ S then x + y ∈ S
Example 2.
(a) Give a recursive definition for the set of positive integers that are not
divisible by 3
(b) Give a recursive definition for the set of integers that are not divisible
by 3
Basic step: 3 ∈ S
Recursive step: If x, y ∈ S then x + y ∈ S
Example 2.
(a) Give a recursive definition for the set of positive integers that are not
divisible by 3
(b) Give a recursive definition for the set of integers that are not divisible
by 3
Basic step: Prove that P is true for elements of S defined in the basic
step.
Basic step: Prove that P is true for elements of S defined in the basic
step.
Recursive step: Show that if the property P is true for the elements
used to construct new elements in the recursive step of the definition
of S, then the property P is also true for these new elements.
Example 2. Let T be a full binary tree with the number of vertices n(T )
and the height h(T ). Prove that n(T ) ≤ 2h(T )+1 − 1.
Example 2. Let T be a full binary tree with the number of vertices n(T )
and the height h(T ). Prove that n(T ) ≤ 2h(T )+1 − 1.
Example.
Example.
Example.
a0,0 = 0, and
Example.
a0,0 = 0,
and
am−1,n + 1 if n = 0 và m > 0,
am,n =
am,n−1 + n if n > 0
Example.
a0,0 = 0,
and
am−1,n + 1 if n = 0 và m > 0,
am,n =
am,n−1 + n if n > 0
Procedure mergesort (L = a1 , a2 , . . . , an )
if n > 1 then
m := bn/2c
L1 = a1 , a2 , . . . , am
L2 = am+1 , am+2 , . . . , an
L := merge(mergesort(L1 ), mergersort(L2 ))
Print (L)
Procedure mergesort (L = a1 , a2 , . . . , an )
if n > 1 then
m := bn/2c
L1 = a1 , a2 , . . . , am
L2 = am+1 , am+2 , . . . , an
L := merge(mergesort(L1 ), mergersort(L2 ))
Print (L)
Theorem
Procedure mergesort (L = a1 , a2 , . . . , an )
if n > 1 then
m := bn/2c
L1 = a1 , a2 , . . . , am
L2 = am+1 , am+2 , . . . , an
L := merge(mergesort(L1 ), mergersort(L2 ))
Print (L)
Theorem
The number of comparisons needed to merge sort a list of n elements is
O(n log n).