




版權(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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 消防安全合同管理規(guī)定
- 船舶制造材料供應(yīng)合同
- 新建住宅買賣合同備案流程
- 股權(quán)轉(zhuǎn)讓合同及相關(guān)權(quán)益轉(zhuǎn)讓協(xié)議
- 股權(quán)轉(zhuǎn)讓居間服務(wù)合同樣本
- 商鋪?zhàn)赓U合同參考模板
- 小班安全玩滑梯課件
- 創(chuàng)業(yè)企業(yè)的股權(quán)結(jié)構(gòu)設(shè)計(jì)考核試卷
- 方便食品的包裝設(shè)計(jì)與人機(jī)工程考核試卷
- 新材料新技術(shù)的巨大潛力探索未知的研究領(lǐng)域考核試卷
- 《水利工程質(zhì)量檢測管理規(guī)定》知識培訓(xùn)
- 2025年02月貴州省司法廳所屬事業(yè)單位公開招聘2人筆試歷年典型考題(歷年真題考點(diǎn))解題思路附帶答案詳解
- 2025年校長春季開學(xué)思政第一課講話稿1720字例文【供參考】
- 2025至2030年中國單板電磁制動器數(shù)據(jù)監(jiān)測研究報(bào)告
- 2024年07月國新國證期貨有限責(zé)任公司(海南)2024年招考2名工作人員筆試歷年參考題庫附帶答案詳解
- 人教版數(shù)學(xué)八年級下冊 第17章 勾股定理 單元測試(含答案)
- 國網(wǎng)標(biāo)書制作流程
- 六年級語文教學(xué)學(xué)情分析提高六語文質(zhì)量的措施
- 中醫(yī)藥臨床適宜技術(shù)
- 銀發(fā)經(jīng)濟(jì)的發(fā)展路徑
- 工業(yè)廠房水電安裝施工方案
評論
0/150
提交評論