ADA算法分析基礎(chǔ)-整體框架_第1頁
ADA算法分析基礎(chǔ)-整體框架_第2頁
ADA算法分析基礎(chǔ)-整體框架_第3頁
ADA算法分析基礎(chǔ)-整體框架_第4頁
ADA算法分析基礎(chǔ)-整體框架_第5頁
已閱讀5頁,還剩28頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、2022-3-2212022-3-222Review of last classbHow to solve a problem by computerbThe notion of algorithm Actual problem Mathematics model Algorithm design and analysis Programming Result analysis Input output finiteness effectiveness definitenessbAlgorithm design pattern2022-3-223How to describe an algor

2、ithm?bNatural language Step1 Input m and n. Step2 Divide m by n and assign the value of the remainder to r. Step3 If r=0, return the value of n as the answer and stop; otherwise, proceed to Step 4. Step4 Assign the value of n to m and the value of r to n. Step5 Go to Step2.Advantages: easy understan

3、dDisadvantages: exist inherent ambiguity2022-3-224How to describe an algorithm? (II)bFlow chartStartr = 0Input m and nr = m % nm = nn = routput nStopA flowchart is a method of expressing an algorithm by a collection of connected geometric shapes containing descriptions of the algorithms steps.Advant

4、ages: intuitiveDisadvantages: lack flexibility2022-3-225How to describe an algorithm? (III)bProgramming languageAdvantages: can run on computer directly Disadvantages: lack abstraction#include int GCD(int m, int n)int r = m % n;while(r!=0)m=n;n=r;r=m%n;return n;void main(void)cout GCD(60,24) 0, then

5、 f(n) = (g(n) f(n) = 2n3+3n-5 = (n3)f(n) = 2n4+1 = (n3) ?( )( )limf ng nnc2022-3-2228Asymptotic Notation: f(n) = (g(n)nf(n)c2g(n)n0c1g(n)2022-3-2229Orders of growth of some important functionsbAll logarithmic functions loga n belong to the same class (log n) no matter what the logarithms base a 1 is

6、bAll polynomials of the same degree k belong to the same class: aknk + ak-1nk-1 + + a0 (nk) bExponential functions an have different orders of growth for different as2022-3-2230Basic asymptotic complexity classesfactorialn!exponential2ncubicn3quadraticn2n-log-nn log nlinearnlogarithmiclog nconstant1

7、2022-3-2231Asymptotic Notation: obo-notation Call f(n) = o(g(n) if there exist positive constants c and n0 such that f(n) cg(n) for all n n0. Or, if , then f(n) = o(g(n)f(n) = 2n3+3n-5 = o(n4) f(n) = o(g(n) if and only if f(n) = O(g(n) ,but g(n) O(f(n) nlogn = o(n2) means that nlogn = O(n2), but n2 O(nlogn)( )( )lim0f ng nn2022-3-2232Asymptotic Notation Using the o-notation, we can concisely express the fo

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論