演算法-联合大学.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Algorithms (Dr. Shi-Jay Chen, National United University) Course 1 演算法: 效率、分析與量級 Algorithms: Efficiency, Analysis, and Order ▓ Outlines 本章重點 Algorithm Def. 與5個性質 Pseudocode The Importance of Developing Efficient Algorithms Analysis of Algorithms Space complexity Time complexity Asymptotic Notation (漸近式表示) Order ?, ?, ?, o, ? Using a Limit to Determine Order ▓ Algorithm 通常在針對某一問題開發程式時,都會經過下列步驟: Step 1: 明確定義問題 Step 2: 設計演算法,並評估其執行效率 Step 3: 撰寫程式,並加以測試 Example: 計算大學入學考試中,某一單科分數之高標 明確定義:計算所有考生在該科中前25%成績之平均。 演算法: Step 1: 將所有考生英文成績排序 (由高至低) Step 2: 將排名在前面1/4的成績資料相加後,再除以1/4的人數 撰寫程式:... Def: The step-by-step procedure that is used to solve the problem is called algorithm. 完成特定功能之有限個指令之集合。同時,需滿足下列5個性質: Input: 外界至少提供?0個輸入 Output: Algorithm至少產生?1個輸出結果 Definiteness (明確): 每個指令必須是Clear and Unambiguous Finiteness (有限性): Algorithm在執行有限個步驟後,必定終止 Effectiveness (有效性): 用紙跟筆即可追蹤Algorithm中執行的過程及結果 其中,Program不一定會滿足特性4,但是Algorithm一定會滿足!! Ex: 軍事防衞系統、提款機系統、作業系統 這就是Program與Algorithm不同之處 Pseudocode (虛擬碼) Example of Pseudocode 問題1: 搜尋問題 範例: 問題演算法: 問題2: 字串完全匹配問題 (The Exact String Matching Problem) Input 字串 P –– the pattern 字串 T –– the text Output 將位於字串T中,與字串 P 完全匹配的位置找出來。 No standard for pseudocode 可以寫得很像英文敘述 也可以寫得很像程式語句 ▓ The Importance of Developing Efficient Algorithms Regardless of how fast computers become or how cheap memory gets, efficiency will always remain an important consideration. 排序問題 (Sorting problem): 將一組資料以遞增 (increasing) 或以遞減 (decreasing)的順序加以排列. 11, 7, 14, 1, 5, 9, 10 ↓sort 1, 5, 7, 9, 10, 11, 14? 欲比較的兩個演算法: Insertion sort: O(n2) Quick sort: O(n log n) 兩個演算法所安裝之系統: Quick Sort: IBM PC/XT (1983年產品,以 Intel 8088 CPU為核心 ) Insertion Sort: VAX8800 (DEC超級迷你電腦) ▓ Analysis of Algorithms To determine how efficiently an algorithm solves a problem, we need to analyze the algorithm. 一個Algorithm的好壞,通常有兩個評估因子: Space (空間): Space Complexity Time (時間): Time Complexity Space Complexity 空間複雜度(S(P))通常來自於兩方面: Fixed Space Requirement: C Instruction Space (即:程式碼大小) 變數 (Simple

文档评论(0)

136****3783 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档