电子科技大学:《算法设计与分析 Design and Analysis of Algorithms》研究生课程教学资源(课件讲稿,英文版)02 Basics of algorithm design & analysis

Design and Analysis of Algorithms 2.Basics of algorithm design analysis Mingyu XIAO School of Computer Science and Engineering University of Electronic Science and Technology of China
Design and Analysis of Algorithms 2. Basics of algorithm design & analysis Mingyu XIAO School of Computer Science and Engineering University of Electronic Science and Technology of China

2.1 Analysis Consider the following problems: 1.What is the difference between polynomial time and exponential time? 2.How to evaluate the running time and space? 3.How to denote the running time or space?
2.1 Analysis Consider the following problems: 1. What is the difference between polynomial time and exponential time? 2. How to evaluate the running time and space? 3. How to denote the running time or space?

How To Measure the Running Time Use a clock to calculate the running time? --May not be good. We Hope:there is a uniform standard for all instances. For most algorithms,the running time and space are related to the size of the input. Different types of running times: Worst case running time.Obtain bound on largest possible running time of algorithm on input of a given size N. Average case running time.Obtain bound on running time of algorithm on random input as a function of input size N. 3
3 How To Measure the Running Time Different types of running times: Worst case running time. Obtain bound on largest possible running time of algorithm on input of a given size N. Average case running time. Obtain bound on running time of algorithm on random input as a function of input size N. Use a clock to calculate the running time? --May not be good. We Hope: there is a uniform standard for all instances. For most algorithms, the running time and space are related to the size of the input

How To Measure the Running Time There are also some other kinds of running times, such as smooth analysis and son. We only consider worst case running time in this course. Questions: Why do we consider worst case running time for most problems? If the worst case running time is W,then there is at least one instance that the running time of it is W?
4 How To Measure the Running Time There are also some other kinds of running times, such as smooth analysis and son. We only consider worst case running time in this course. Questions: Why do we consider worst case running time for most problems? If the worst case running time is W, then there is at least one instance that the running time of it is W?

How To Measure the Running Time Consider this problem:Max independent set problem To find a vertex set of max cardinality in a given graph such that no pair of vertices in the set are adjacent. A Brute force method for this problem:For many non-trivial problems,there is a natural brute force search algorithm that checks every possible solution. What is the worst case running time of this algorithm? It takes 2N time for inputs of size N(N vertices). (any problem for this algorithm?)
5 How To Measure the Running Time Consider this problem: Max independent set problem To find a vertex set of max cardinality in a given graph such that no pair of vertices in the set are adjacent. A Brute force method for this problem: For many non-trivial problems, there is a natural brute force search algorithm that checks every possible solution. What is the worst case running time of this algorithm? It takes 2N time for inputs of size N (N vertices). (any problem for this algorithm?)

A Famous Story ·在席·盖莫夫著的《从一到无穷大》中记载着一个关于古印度舍罕王 (Shirham)的故事: 舍罕王打算重赏“国际象棋”(真正的国际 象棋是后来进化演变来的)的发明人和进贡者, 宰相西萨.班·达伊尔(Sissa Ben Dahir)。这位 聪明的大臣的胃口看来并不大,他跪在国王面 前说:“陛下,请您在这张棋盘的第一个小格 内,赏给我一粒麦子;在第二个小格内两粒, 第三个给四粒,照这样下去,每个小格内都比 以前一个小格加一倍。陛下啊,把这样摆满棋 盘上所有64格的麦粒,都赏给您的仆人罢!” 舍罕王听后很生气,说:”你也太小看我 们印度国了,我拿一袋子麦子全给你好了。“ 西萨班·达伊尔坚持说还是按要求放满好。最后大家拿了许多袋麦子 过来都只完成了一小部分的填充工作,大家这才感觉到问题的严重。 6
6 A Famous Story 在席·盖莫夫著的《从一到无穷大》中记载着一个关于古印度舍罕王 (Shirham)的故事: 舍罕王打算重赏“国际象棋”(真正的国际 象棋是后来进化演变来的)的发明人和进贡者, 宰相西萨·班·达伊尔(Sissa Ben Dahir)。这位 聪明的大臣的胃口看来并不大,他跪在国王面 前说:“陛下,请您在这张棋盘的第一个小格 内,赏给我一粒麦子;在第二个小格内两粒, 第三个给四粒,照这样下去,每个小格内都比 以前一个小格加一倍。陛下啊,把这样摆满棋 盘上所有64格的麦粒,都赏给您的仆人罢!” 舍罕王听后很生气,说:”你也太小看我 们印度国了,我拿一袋子麦子全给你好了。“ 西萨·班·达伊尔坚持说还是按要求放满好。最后大家拿了许多袋麦子 过来都只完成了一小部分的填充工作,大家这才感觉到问题的严重

Why It Matters Table 2.1 The running times (rounded up)of different algorithms on inputs of increasing size,for a processor performing a million high-level instructions per second. In cases where the running time exceeds 1025 years,we simply record the algorithm as taking a very long time. n n log2 n n2 n3 1.5m 2n n! n=10 <1 sec <1 sec <1sec <1 sec <1 sec <1 sec 4 sec n=30 <1 sec <1 sec <1 sec <1 sec <1 sec 18 min 1025 years n=50 <1 sec <1 sec <1 sec <1 sec 11 min 36 years very long n=100 <1 sec <1 sec <1 sec 1sec 12,892 years 1017 years very long n=1,000 <1 sec <1 sec 1 sec 18 min very long very long very long n=10,000 <1 sec <1 sec 2 min 12 days very long very long very long n=100,000 <1 sec 2 sec 3 hours 32 years very long very long very long n=1,000,000 1 sec 20 sec 12 days 31,710 years very long very long very long 7
7 Why It Matters

What It Matters Shirham's story. The amount of wheat 0 1 2 3 0g00g 23 0884 63 20 21 22 23 年 223 4等 263 1 2 4 8 8388608 9223372036854775808 Sum 3 15 48gte 16777215 55g08: 18446744073709551615 It takes more than 2,000,000 years for a modern computer to count the wheat! Brute force solution to the max impendent set problem. If the graph has 100 vertices, Number of solution:2100= 1267650600228229401496703205376 8
8 What It Matters Shirham’s story. The amount of wheat 0 1 2 3 …… 23 …… 63 20 21 22 23 …… 223 …… 263 1 2 4 8 …… 8388608 …… 9223372036854775808 Sum 3 7 15 …… 16777215 …… 18446744073709551615 Brute force solution to the max impendent set problem. If the graph has 100 vertices, Number of solution: 2100= 1267650600228229401496703205376 It takes more than 2,000,000 years for a modern computer to count the wheat!

Polynomial and_exponential (多项式和指数) 上表中我们可以观察到n3和3n有巨大差别。 这个差别就是指数与多项式的差别。 在n3和3n中,如果n变成2n的话(也就是输入增大一 倍),两个数分别是以前的多少倍? 对于n3来说,是8倍,一个常数倍; 对于3n来说,是3n倍,这个倍数与n有关。 指数增长是恐怖的,在算法运行时间中应当尽量避免。很 多问题很容易就可以给出一个指数运行时间的穷举搜索算 法,但是否都存在多项式算法?(计算机科学的核心问题) 是否每个多项式时间的算法都有效?
9 Polynomial and exponential (多项式和指数) 上表中我们可以观察到 n 3 和 3 n 有巨大差别。 这个差别就是指数与多项式的差别。 在n 3 和 3 n 中,如果n变成2n的话(也就是输入增大一 倍),两个数分别是以前的多少倍? 对于 n 3 来说,是8倍,一个常数倍; 对于 3 n 来说,是3 n倍,这个倍数与n有关。 指数增长是恐怖的,在算法运行时间中应当尽量避免。很 多问题很容易就可以给出一个指数运行时间的穷举搜索算 法,但是否都存在多项式算法?(计算机科学的核心问题) 是否每个多项式时间的算法都有效?

数量级的差别 对于一个输入为n的问题,现给出两个算法A和B. 算法A运行100n步,算法B运行nlogn步。 哪个算法好? 若算法A运行n2+100n步,算法B运行2n2步。 哪个算法好? 很多时候我们认为n和n2之间的差异是较大的,而n和5n之 间的差异是微小的甚至可以忽悠不计的,怎样表达这种差 异? 用渐进表达式可以解决这个问题。 就算都是多项式,也需表现差异 0
10 数量级的差别 对于一个输入为n的问题,现给出两个算法A和B. 算法A运行100n步,算法B运行nlogn步。 哪个算法好? 就算都是多项式,也需表现差异 若算法A运行n 2+100n步,算法B运行2n2步。 哪个算法好? 很多时候我们认为n和n 2之间的差异是较大的,而n和5n之 间的差异是微小的甚至可以忽悠不计的,怎样表达这种差 异? 用渐进表达式可以解决这个问题
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 电子科技大学:《算法设计与分析 Design and Analysis of Algorithms》研究生课程教学资源(课件讲稿,英文版)Stable Matching.pdf
- 电子科技大学:《算法设计与分析 Design and Analysis of Algorithms》研究生课程教学资源(课件讲稿,英文版)01 Introduction(肖鸣宇).pdf
- 上饶师范学院:《数据库系统原理 An Introduction to Database System》课程教学资源(电子教案,颜清).doc
- 电子科技大学:《算法设计与分析 Algorithms Design and Analysis》课程教学资源(课件讲稿)第六章 分支限界法(Branch and Bound Method).pdf
- 电子科技大学:《算法设计与分析 Algorithms Design and Analysis》课程教学资源(课件讲稿)第五章 回朔法(Backtracking Algorithm).pdf
- 电子科技大学:《算法设计与分析 Algorithms Design and Analysis》课程教学资源(课件讲稿)第四章 贪心算法(Greedy Algorithm).pdf
- 电子科技大学:《算法设计与分析 Algorithms Design and Analysis》课程教学资源(课件讲稿)第三章 动态规划 Dynamic Programming.pdf
- 电子科技大学:《算法设计与分析 Algorithms Design and Analysis》课程教学资源(课件讲稿)第二章 递归与分治策略.pdf
- 电子科技大学:《算法设计与分析 Algorithms Design and Analysis》课程教学资源(课件讲稿)第一章 算法概述 Algorithm Introduction(刘瑶、陈佳).pdf
- 电子科技大学:《数据分析与数据挖掘 Data Analysis and Data Mining》课程教学资源(课件讲稿)Lecture 06 Classification.pdf
- 电子科技大学:《数据分析与数据挖掘 Data Analysis and Data Mining》课程教学资源(课件讲稿)Lecture 04 Association Rules of Data Reasoning.pdf
- 电子科技大学:《数据分析与数据挖掘 Data Analysis and Data Mining》课程教学资源(课件讲稿)Lecture 04 Association Rules of Data Reasoning(FP-growth Algorithm).pdf
- 电子科技大学:《数据分析与数据挖掘 Data Analysis and Data Mining》课程教学资源(课件讲稿)Lecture 04 Association Rules of Data Reasoning(Apriori Algorithm、Improve of Apriori Algorithm).pdf
- 电子科技大学:《数据分析与数据挖掘 Data Analysis and Data Mining》课程教学资源(课件讲稿)Lecture 05 Clustering Analysis.pdf
- 电子科技大学:《数据分析与数据挖掘 Data Analysis and Data Mining》课程教学资源(课件讲稿)Lecture 03 Regression Analysis and Classification.pdf
- 电子科技大学:《数据分析与数据挖掘 Data Analysis and Data Mining》课程教学资源(课件讲稿)Lecture 03 Regression Analysis(Logistic Regression).pdf
- 电子科技大学:《数据分析与数据挖掘 Data Analysis and Data Mining》课程教学资源(课件讲稿)Lecture 02 Raw Data Analysis and Pre-processing(2.1-2.4).pdf
- 电子科技大学:《数据分析与数据挖掘 Data Analysis and Data Mining》课程教学资源(课件讲稿)Lecture 02 Raw Data Analysis and Pre-processing(2.5-2.7).pdf
- 电子科技大学:《数据分析与数据挖掘 Data Analysis and Data Mining》课程教学资源(课件讲稿)Lecture 01 Overview Data Analysis and Data Mining(李晓瑜).pdf
- 电子科技大学:《数据分析与数据挖掘 Data Analysis and Data Mining》课程教学资源(课件讲稿)量子降维算法.pdf
- 电子科技大学:《算法设计与分析 Design and Analysis of Algorithms》研究生课程教学资源(课件讲稿,英文版)03 Maximum Flow.pdf
- 电子科技大学:《算法设计与分析 Design and Analysis of Algorithms》研究生课程教学资源(课件讲稿,英文版)04 NP and Computational Intractability.pdf
- 电子科技大学:《算法设计与分析 Design and Analysis of Algorithms》研究生课程教学资源(课件讲稿,英文版)05 Approximation Algorithms.pdf
- 电子科技大学:《现代密码理论 Modern Cryptographic Theory》课程教学资源(课件讲稿)第1章 概述(李发根).pdf
- 电子科技大学:《现代密码理论 Modern Cryptographic Theory》课程教学资源(课件讲稿)第2章 古典密码.pdf
- 电子科技大学:《现代密码理论 Modern Cryptographic Theory》课程教学资源(课件讲稿)第3章 流密码.pdf
- 电子科技大学:《现代密码理论 Modern Cryptographic Theory》课程教学资源(课件讲稿)第4章 分组密码.pdf
- 电子科技大学:《现代密码理论 Modern Cryptographic Theory》课程教学资源(课件讲稿)第5章 Hash函数.pdf
- 电子科技大学:《现代密码理论 Modern Cryptographic Theory》课程教学资源(课件讲稿)第6章 公钥密码(一)6.1-6.4.pdf
- 电子科技大学:《现代密码理论 Modern Cryptographic Theory》课程教学资源(课件讲稿)第6章 公钥密码(二)6.5-6.9.pdf
- 电子科技大学:《现代密码理论 Modern Cryptographic Theory》课程教学资源(课件讲稿)第7章 数字签名.pdf
- 电子科技大学:《现代密码理论 Modern Cryptographic Theory》课程教学资源(课件讲稿)第8章 密码协议.pdf
- 中国科学技术大学:《网络安全》课程教学资源(课件讲稿)第1章 概述(主讲:曾凡平).pdf
- 中国科学技术大学:《网络安全》课程教学资源(课件讲稿)第2章 基础知识.pdf
- 中国科学技术大学:《网络安全》课程教学资源(课件讲稿)第3章 密码学基础.pdf
- 中国科学技术大学:《网络安全》课程教学资源(课件讲稿)第4章 虚拟专用网络(VPN)技术.pdf
- 《网络与系统安全》教学参考文献:An adaptive trust model based on recommendation filtering algorithm for the Internet of Things systems.pdf
- 《网络与系统安全》教学参考文献:Automatic Generation of Capability Leaks’ Exploits for Android Applications.pdf
- 《网络与系统安全》教学参考文献:Adaptive Random Testing for XSS Vulnerability.pdf
- 《网络与系统安全》教学参考文献:A Novel Hybrid Model for Task Dependent Scheduling in Container-based Edge Computing.pdf