Discrete Mathematics Chapter 6 Advanced Counting Techniques.

Slides:



Advertisements
Similar presentations
Chapter Recurrence Relations
Advertisements

1 生物計算期末作業 暨南大學資訊工程系 2003/05/13. 2 compare f1 f2  只比較兩個檔案 f1 與 f2 ,比完後將結果輸出。 compare directory  以兩兩比對的方式,比對一個目錄下所有檔案的相 似程度。  將相似度很高的檔案做成報表輸出,報表中至少要.
1 Chapter 5 Pólya’s throry of counting 5.1 簡介 5.2 重排群的等價類 (equivalence classes under a permutation group) 5.3 函數的等價類 5.4 函數的權重 (weight) 和目錄 (inventories)
: Arrange the Numbers ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 11481: Arrange the Numbers 解題者:李重儀 解題日期: 2008 年 9 月 13 日 題意: 將數列 {1,2,3, …,N}
布林代數的應用--- 全及項(最小項)和全或項(最大項)展開式
:Word Morphing ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10508:word morphing 解題者:楊家豪 解題日期: 2006 年 5 月 21 日 題意: 第一行給你兩個正整數, 第一個代表下面會出現幾個字串,
1 Q10276: Hanoi Tower Troubles Again! 星級 : ★★★ 題組: Online-judge.uva.es PROBLEM SET Volume CII 題號: Q10276: Hanoi Tower Troubles Again! 解題者:薛祖淵 解題日期: 2006.
1 集合論 Chapter 3. 2 Chapter 3 Set Theory 3.1 Sets and Subsets A well-defined collection of objects (the set of outstanding people, outstanding is very.
Advanced Chemical Engineering Thermodynamics
指導教授:陳淑媛 學生:李宗叡 李卿輔.  利用下列三種方法 (Edge Detection 、 Local Binary Pattern 、 Structured Local Edge Pattern) 來判斷是否為場景變換,以方便使用者來 找出所要的片段。
1.1 線性方程式系統簡介 1.2 高斯消去法與高斯-喬登消去法 1.3 線性方程式系統的應用(-Skip-)
1 Advanced Chemical Engineering Thermodynamics Appendix BK The Generalized van der Waals Partition Function.
Lecture 8 Median and Order Statistics. Median and Order Statistics2 Order Statistics 問題敘述 在 n 個元素中,找出其中第 i 小的元素。 i = 1 ,即為找最小值。 i = n ,即為找最大值。 i = 或 ,即為找中位數。
Review of Chapter 3 - 已學過的 rules( 回顧 )- 朝陽科技大學 資訊管理系 李麗華 教授.
STAT0_sampling Random Sampling  母體: Finite population & Infinity population  由一大小為 N 的有限母體中抽出一樣本數為 n 的樣 本,若每一樣本被抽出的機率是一樣的,這樣本稱 為隨機樣本 (random sample)
Introduction to Java Programming Lecture 17 Abstract Classes & Interfaces.
:Problem D: Bit-wise Sequence ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10232: Problem D: Bit-wise Sequence 解題者:李濟宇 解題日期: 2006 年 4 月 16.
7 陣列與搜尋 7.1 陣列 一般資料變數 宣告一維陣列 起始一維陣列 7-4
: Happy Number ★ ? 題組: Problem Set Archive with Online Judge 題號: 10591: Happy Number 解題者:陳瀅文 解題日期: 2006 年 6 月 6 日 題意:判斷一個正整數 N 是否為 Happy Number.
3.1 矩陣的行列式 3.2 使用基本運算求行列式 3.3 行列式的性質 3.4 特徵值介紹 3.5 行列式的應用
Fourier Series. Jean Baptiste Joseph Fourier (French)(1763~1830)
CH 15- 元件可靠度之驗證  驗證方法  指數模式之可靠度驗證  韋式模式之可靠度驗證  對數常態模式之可靠度驗證  失效數為零時之可靠度估算  各種失效模式之應用.
Fugacity Coefficient and Fugacity
: Multisets and Sequences ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11023: Multisets and Sequences 解題者:葉貫中 解題日期: 2007 年 4 月 24 日 題意:在這個題目中,我們要定義.
:Nuts for nuts..Nuts for nuts.. ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 10944:Nuts for nuts.. 解題者:楊家豪 解題日期: 2006 年 2 月 題意: 給定兩個正整數 x,y.
資料結構實習-一 參數傳遞.
第六章 陣列.
1 Finite Continued Fractions 田錦燕 94/11/03 95/8/9( 最後更新 )
Lecture 7 Sorting in Linear Time. Sorting in Linear Time2 7.1 Lower bounds for sorting 本節探討排序所耗用的時間複雜度下限。 任何一個以比較為基礎排序的演算法,排序 n 個元 素時至少耗用 Ω(nlogn) 次比較。
: Problem G e-Coins ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10306: Problem G e-Coins 解題者:陳瀅文 解題日期: 2006 年 5 月 2 日 題意:給定一個正整數 S (0
: Beautiful Numbers ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11472: Beautiful Numbers 解題者:邱經達 解題日期: 2011 年 5 月 5 日 題意: 若一個 N 進位的數用到該.
Section 4.2 Probability Models 機率模式. 由實驗看機率 實驗前先列出所有可能的實驗結果。 – 擲銅板:正面或反面。 – 擲骰子: 1~6 點。 – 擲骰子兩顆: (1,1),(1,2),(1,3),… 等 36 種。 決定每一個可能的實驗結果發生機率。 – 實驗後所有的實驗結果整理得到。
演算法 8-1 最大數及最小數找法 8-2 排序 8-3 二元搜尋法.
845: Gas Station Numbers ★★★ 題組: Problem Set Archive with Online Judge 題號: 845: Gas Station Numbers. 解題者:張維珊 解題日期: 2006 年 2 月 題意: 將輸入的數字,經過重新排列組合或旋轉數字,得到比原先的數字大,
Chapter 2. Recurrence Relations (遞迴關係)
2005/7 Linear system-1 The Linear Equation System and Eliminations.
: DELIVERY DEBACLE ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11310: DELIVERY DEBACLE 解題者:黃韋竣 解題日期: 2011 年 6 月 9 日 題意:有一個人, 有個特別的習慣 I.
Visual C++重點複習.
: SAM I AM ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11419: SAM I AM 解題者:李重儀 解題日期: 2008 年 9 月 11 日 題意: 簡單的說,就是一個長方形的廟裡面有敵人,然 後可以橫的方向開砲或縱向開砲,每次開砲可以.
: Bee Maja ★★☆☆☆ 題組: Contests Hosting Service with Online Judge 題號: 10182: Bee Maja 解題者:林祺光、李哲宇 解題日期: 2006 年 3 月 26 日 題意:現有兩種六邊形座標系,將甲座標系的某一點轉 為相對應的乙座標系。
: Finding Paths in Grid ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11486: Finding Paths in Grid 解題者:李重儀 解題日期: 2008 年 10 月 14 日 題意:給一個 7 個 column.
:Problem E.Stone Game ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10165: Problem E.Stone Game 解題者:李濟宇 解題日期: 2006 年 3 月 26 日 題意: Jack 與 Jim.
6.Advanced Counting Techniques 1 Copyright M.R.K. Krishna Rao 2003 Ch 6. Recurrence Relations A recurrence relation for the sequence {a n } is an equation.
: How many 0's? ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11038: How many 0’s? 解題者:楊鵬宇 解題日期: 2007 年 5 月 15 日 題意:寫下題目給的 m 與 n(m
Discrete Mathematics Chapter 4 Induction and Recursion 大葉大學 資訊工程系 黃鈴玲 (Lingling Huang)
Applied Discrete Mathematics Week 9: Relations
Advanced Counting Techniques
Discrete Mathematics Chapter 4 Counting 感謝 大葉大學 資訊工程系 黃鈴玲老師 提供.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Discrete Mathematics Chapter 3 Mathematical Reasoning, Induction, and Recursion 感謝 大葉大學 資訊工程系 黃鈴玲老師 提供.
CSE 2813 Discrete Structures Recurrence Relations Section 6.1.
Discrete Mathematics Chapter 7 Advanced Counting Techniques 大葉大學 資訊工程系 黃鈴玲.
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/18 Module.
Chapter 2 Combinatorial Analysis 主講人 : 虞台文. Content Unordered Samples without Replacement  Combinations Binomial Coefficients Some Useful Mathematic.
Chapter 7 Advance Counting Techniques. Content Recurrence relations Generating function The principle of inclusion-exclusion.
Chapter 2 Combinatorial Analysis 主講人 : 虞台文. Content Basic Procedure for Probability Calculation Counting – Ordered Samples with Replacement – Ordered.
Chapter 8 With Question/Answer Animations. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Discrete Mathematics Chapter 2 Basic Structures : Sets, Functions, Sequences, and Sums 大葉大學 資訊工程系 黃鈴玲 (Lingling Huang)
Discrete Mathematics Chapter 7 Relations 感謝 大葉大學 資訊工程系 黃鈴玲老師 提供.
Discrete Mathematics Section 3.7 Applications of Number Theory 大葉大學 資訊工程系 黃鈴玲.
Discrete Mathematics Chapter 5 Counting.
Discrete Mathematics Chapter 5 Counting 大葉大學 資訊工程系 黃鈴玲.
CMSC Discrete Structures
Advanced Counting Techniques
CMSC Discrete Structures
CMSC Discrete Structures
Recurrence Relations Discrete Structures.
Chapter 7 Advanced Counting Techniques
ICS 253: Discrete Structures I
Presentation transcript:

Discrete Mathematics Chapter 6 Advanced Counting Techniques

7.1Recurrence Relations( 遞迴關係 ) Example 1. Let {a n } be a sequence that satisfies the recurrence relation a n = a n  1  a n  2 for n=2,3,…, and suppose that a 0 =3,and a 1 =5. Here a 0 =3 and a 1 =5 are the initial conditions. By the recurrence relation, a 2 = a 1  a 0 = 2 a 3 = a 2  a 1 =  3 a 4 = a 3  a 2 =  5 : Q1: Applications ? Q2: Are there better ways for computing the terms of {a n } ?

※ Modeling with Recurrence Relations We can use recurrence relations to model (describe) a wide variety of problems. Example 3. Compound Interest ( 複利 ) Suppose that a person deposits( 存款 ) $10000 in a saving account at a bank yielding 11% per year with interest compounded annually. How much will be in the account after 30 years ? Sol : Let P n denote the amount in the account after n years. P n =P n   P n  1 =1.11  P n  1, ∴ P 30 =1.11  P 29 =(1.11) 2  P 28 =…=(1.11) 30  P 0 = P 0 =10000

Example 5. (The Tower of Hanoi) The rules of the puzzle allow disks to be moved one at a time from one peg to another as long as a disk is never placed on top of a smaller disk. Let H n denote the number of moves needed to solve the Tower of Hanoi problem with n disks. Set up a recurrence relation for the sequence {H n }. Sol : H n =2H n-1 +1, ( n  1 個 disk 先從 peg 1 →peg 3, 第 n 個 disk 從 peg 1 →peg 2, n  1 個 disk 再從 peg 3 →peg 2 ) peg 1 peg 2peg 3 H 4 moves 目標 : n 個 disk 都從 peg 1 移到 peg 2 H 1 =1

上例中 H n =2H n  1 +1, H 1 =1 ∴ H n =2H n  1 +1 =2(2H n  2 +1)+1 =2 2 H n  =2 2 (2H n  3 +1)+2+1 =2 3 H n  3 +( ) : =2 n  1 H 1 +(2 n  2 +2 n  3 +…+1) =2 n  1 +2 n  2 +…+1 = =2 n  1

Example 6. Find a recurrence relation and give initial conditions for the number of bit strings of length n that do not have two consecutive 0 s. How many such bit strings are there of length 5 ? Sol : ∴ a n = a n  1 +a n  2, n  3 a 1 =2 (string : 0,1) a 2 =3 (string : 01,10,11) ∴ a 3 =a 2 +a 1 =5, a 4 =8, a 5 =13 1 a n-1 種 a n-2 種 1 0 n-2n-1n 1 2 n-3 …

Example 7. (Codeword enumeration) A computer system considers a string of decimal digits a valid codeword if it contains an even number of 0 digits. Let a n be the number of valid n -digit codewords. Find a recurrence relation for a n. Sol : 1~9 an1 種an1 種 10 n  1  a n  1 種 0 ∴ a n = 9a n  1 + (10 n  1  a n  1 ) = 8a n  n  1, n  2 a 1 = 9 n-1 n …

求 a n 通解 : Exercise : 3,23,25,27,29,41 (41 推廣成 n )

7.2 Solving Recurrence Relations Def 1. A linear homogeneous recurrence relation of degree k (i.e., k terms) with constant coefficients is a recurrence relation of the form where c i  R and c k ≠ 0 Example 1 and 2. f n = f n  1 + f n  2 a n = a n  5 a n = a n  1 + a n  2 2 a n = na n  1 H n = 2H n  a n = c 1 a n  1 +c 2 a n  2 +…+c k a n  k (True, deg=2) (True, deg=5) (False, 不是 linear) (False, 不是 linear, not constant coeff. ) (False, 不是 homogeneous)

Theorem 1. Let a n = c 1 a n  1 + c 2 a n  2 be a recurrence relation with c 1, c 2  R. If r 2  c 1 r  c 2 = 0 ( 稱為 characteristic equation) has two distinct roots r 1 and r 2. Then the solution of a n is a n =  1 r 1 n +  2 r 2 n, for n=0,1,2,…, where  1,  2 are constants. (  1,  2 可利用 a 0, a 1 算出 )

Example 3. What’s the solution of the recurrence relation a n = a n  1 + 2a n  2 with a 0 =2 and a 1 =7 ? Sol : The characteristic equation is r 2 – r  2=0. Its two roots are r 1 = 2 and r 2 =  1. Hence a n =  1  2 n +  2  (  1) n. ∵ a 0 =  1  2 = 2, a 1 =2  1  2 =7 ∴  1 = 3,  2 =  1  a n = 3  2 n  (  1) n. 驗算: a 2 = a 1 + 2a 0 =11 a 2 = 3  2 2  1 =11

Example 4. Find an explicit formula for the Fibonacci numbers. Sol : f n = f n  1 + f n  2, n  2, f 0 =0, f 1 =1. The characteristic equation is r 2  r  1=0. Its two roots are,. So we have

Thm 2. Let a n = c 1 a n  1 +c 2 a n  2 be a recurrence relation with c 1,c 2  R. If r 2  c 1 r  c 2 = 0 has only one root r 0. Then the solution of a n is a n =  1  r 0 n +  2  n  r 0 n for n=0,1,2,…, where  1 and  2 are constants.

Example 5. What’s the solution of a n = 6a n  1  9a n  2 with a 0 =1 and a 1 =6 ? Sol : The root of r 2  6r + 9 = 0 is r 0 = 3. Hence a n =  1 . 3 n +  2 . n . 3 n. ∵ a 0 =  1 = 1 a 1 = 3   2 = 6 ∴  1 = 1 and  2 = 1  a n = 3 n + n . 3 n 驗算: a 2 = 6a 1  9a 0 =27 a 2 =  3 2 =27

Thm 3. Let a n = c 1 a n  1 + c 2 a n  2 + … + c k a n  k be a recurrence relation with c 1, c 2, …, c k  R. If r k  c 1 r k-1  c 2 r k-2  …  c k = 0 has k distinct roots r 1, r 2,…, r k. Then the solution of a n is a n =  1 r 1 n +  2 r 2 n + …+  k r k n, for n = 0, 1, 2, … where  1,  2,…  k are constants.

Example 6 ( k = 3) Find the solution of a n = 6a n  1  11a n  2 + 6a n  3 with initial conditions a 0 =2, a 1 =5 and a 2 =15. Sol : The roots of r 3  6r r – 6 = 0 are r 1 = 1, r 2 = 2, and r 3 = 3 ∴ a n =  1  1 n +  2  2 n +  3  3 n ∵ a 0 =  1 +  2 +  3 = 2 a 1 =    3 = 5 a 2 =    3 = 15 ∴ a n = 1  2 n + 2  3 n  1 = 1,  2 =  1,  3 = 2 驗算: a 3 = 6a 2  11a 1 + 6a 0 =47 a 3 = 1   3 3 =47

Thm 4. Let a n = c 1 a n  1 + c 2 a n  2 + … + c k a n  k be a recurrence relation with c 1, c 2, …, c k  R. If r k  c 1 r k  1  c 2 r k  2  …  c k = 0 has t distinct roots r 1, r 2, …, r t with multiplicities m 1, m 2, …, m t respectively, where m i  1,  i, and m 1 + m 2 +…+ m t = k, then ( 接下一頁 )

where  i,j are constants. ( 1  i  t, 0  j  m i  1 )

Example 8. Find the solution to the recurrence relation a n =  3a n  1  3a n  2  a n  3 with initial conditions a 0 = 1, a 1 =  2 and a 2 =  1. Sol : r 3 + 3r 2 + 3r + 1 = 0 has a single root r 0 =  1 of multiplicity three. ∴ a n = (  1 +  2 n+  3 n 2 ) r 0 n = (  1 +  2 n+  3 n 2 )(  1) n ∵ a 0 =  1 = 1 a 1 = (  1 +  2 +  3 )  (  1) =  2 a 2 = (  1 +  2 +  3 ) =  1 ∴  1 = 1,  2 = 3,  3 =  2  a n = (1+3n  2n 2 )  (  1) n Exercise : 3,13,15,19 驗算: a 3 =  3a 2  3a 1  a 0 =8 a 3 = (1+3  3  2  3 2 )  (  1) 3 =8

7.4 Generating Functions. Def 1. The generating function for the sequence {a n } is the infinite power series. G(x) = a 0 + a 1 x +… + a n x n +… = ( 若 {a n } 是 finite ,可視為是 infinite ,但後面的 term 都等於 0 )

Example 2. What is the generating function for the sequence 1,1,1,1,1,1 ? Sol : (expansion ,展開式 ) (closed form)

Example 3. Let m  Z + and,for k = 0, 1, …, m. What is the generating function for the sequence a 0, a 1,…, a m ? Sol : G(x) = a 0 + a 1 x + a 2 x 2 + … + a m x m = (1+x) m (by 二項式定理 )

Example 5. The function f (x) = is the generating function of the sequence 1, a, a 2, …, since = 1 + ax + a 2 x 2 + …= when |ax| < 1 for a≠0

Def 2. Let u  R and k  Z + ∪ {0}. Then the extended binomial coefficient is defined by

Example 7. Find and Sol :

Thm 2. (The Extended Binomial Theorem) Let x  R with |x|<1 and let u  R, then

Example 9. Find the generating functions for (1+x)  n and (1  x)  n where n  Z + Sol : By the Extended Binomial Theorem, By replacing x by –x we have Def 2.

※ Using Generating Functions to solve Recurrence Relations. Example 16. Solving the recurrence relation a k = 3a k  1 for k=1,2,3,… and initial condition a 0 = 2. Sol : 另法: (by 7.2 公式 ) r – 3 = 0  r = 3  a n =  3 n ∵ a 0 = 2 =  ∴ a n = 2  3 n

Let be the generating function for {a k }. First note that a k x k = 3a k  1 x k   G(x)  a 0 = 3x  G(x)  ∵ a 0 = 2  G(x)  3x  G(x) = G(x)(1  3x) = 2 ∴ a k = 2  3 k Exercise : 5,7,11,33

7.5 Inclusion-Exclusion 排容原理 A,B,C,D : sets A B C |A|+|B|+|C| 時 各部分被計算的次數 |A  B  C| 後 -|A  B|-|A  C|-|B  C| 後

Theorem 1. A 1, A 2, …, A n : sets Exercise : 17

7.6 Applications of Inclusion and Exclusion Example 2. How many onto functions are there form set A={1, 2, 3, 4, 5, 6} to set B={a, b, c} ? Sol : f : A → B f (1)= {a, b, c} f (2)= ︰ f (6)= 不同的填法造出不同的函數 如何使 a,b,c 都出現 ? # of onto functions = ( 所有函數個數 )  ( a,b,c 中有一個沒被對應 ) + ( a,b,c 中二個沒被對應 )  ( a,b,c 都沒被對應 ) =

Thm 1. |A| = m, |B| = n There are onto functions f : A → B. pf : A = {a 1, a 2, …, a m }. B = {b 1, b 2, …, b n } f (a 1 )= f (a 2 )= ︰ f (a m )= b 1, b 2, …, b n

※ Derangements 亂序 Def. A derangement is a permutation of objects that leaves no object in its original position.

D 4 = ( 所有 4 個元素的 permutation 數 )  ( 4 個元素有一個在原位置的 permutation 數 ) + ( 4 元素中有二個在原位置的個數 )  ( 4 個元素中有三個在原位置的個數 ) + ( 4 元素都在原位置的個數 ) = Example 5. derangements of : Let D n denote the number of derangements of n objects , 23451, 34512, … Def.

Theorem 2. ( 亂序公式 ) Exercise : 8 參考: 12,13