算法分析大纲.docx

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
算法分析大纲

算法的定义An algorithm is a sequence of unambiguous instructions for solving a computational problem, obtaining a required output for any legitimate input in a finite amount of time.算法是一系列解决问题的清晰指令,也就是说,对于符合一定规范的输入,能够在有限时间内获得所要求的输出。算法的特点Finiteness DefinitenessInputOutputEffectiveness算法的设计步骤Understanding the problem. Read the problem description carefully and ask question if you have any doubts about the problems.Deciding on.deciding on appropriate data structures.Designing an algorithm. An algorithm design technique is a general approach to solving problems algorithmically that is applicable to a variety of problems from different areas of computingProving correctness. The notions of correctness of approximation algorithm is less straightforward than it is for exact algorithm.Analyzing an algorithm. Time efficiency indicates how fast the algorithm runs, space efficiency indicates how much extra memory the algorithm needs.Coding the algorithm. Most algorithm are destined to be ultimately implemented as computer programs. Programming an algorithm presents both a peril and an opportunity.算法效率Time efficiencySpace efficiency增长次数比较1 logn n nlogn n2 n3 2的n次方 n!蛮力法定义A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved.蛮力法是一种简单直接地解决问题的方法,通常直接基于问题的描述和所涉及的概念定义。蛮力法优缺点Strengths :1 wide applicability 2 simplicity 3yields reasonable algorithms for some important problems(e.g., matrix multiplication, sorting, searching, string matching) Weaknesses:1 rarely yields efficient algorithms 2some brute-force algorithms are unacceptably slow not as constructive as some other design techniques选择排序和冒泡排序两个算法的比较Selection Sort Bubble Sort 1Stability: Selection Sort is instable ;Bubble Sort is stable2Efficiency:Selection Sort n2;Bubble Sort n23Comparion number: Selection Sort :n(n-1)/2 Bubble Sort: n(n-1)/24input size:n解决背包问题过程和分析W1=7 v1=42 w2=3 v2=12 w3=4 v3=40 w4=5 v4=25 背包W=10子集Subset总重量Total weight总价值 Total value空00{1}7

文档评论(0)

yaocen + 关注
实名认证
内容提供者

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

1亿VIP精品文档

相关文档