Introduction to Algorithms算法导论笔记-Lecture1
2016-06-07 22:35
495 查看
Introduction to Algorithms算法导论笔记
算法导论Lesson1课程简介:
内容主要包括:算法的含义、意义的简要介绍;
算法的分析;
插入排序、合并排序
如下图:
如下图:
preface
Analysis of Algorithms
The theoretical study of computer program
performance and resource usage
What’s more important than perf?
cost, ux
Why study algs and perf?
infeasable ->feasable
perf like the currency in economy
Perf is the precondition to have good ux.
bottom of heap
Speed is always fun.
Problem Sorting
input sequence [a1,a2,…,an] of numbers
output permutation[a1’,a2’,…,an’] to sorted as smaller->bigger
Insertion Sort
Running time:
- depends on input(e.g. sorted already)
- depends on input size( 6 elem. vs 6*10**9)
Kinds of analysis
Worst-case(usually)
T(n) =max time on any input of size n
Average-case:(sometimes)
T(n)=expected time over all inputs of size n
(Need assumption of stat. distr.)
Best-case:(bogus)
cheat
What’s my sort’s worst time?
Depends on computer
relative speed(on same machine)
absolute speed(on different machines)
BIG DATA
渐进分析
look at the growth of time when n->infinity
Asymptotic notation:
O(n**3) Drop low-order such as n**2,n,constant and leading constant.
arithmetic series(算术级数,等差级数)
教授居然说,我们这里有高手知道算数级数,沟通就好办了。
Merge Sort
If n=1, done
Recursively sort
a[1,…n/2] and
a[n/2+1,…n]
Merge 2 sorted lists.
Key Subroutine: Merge
20 12
13 11
7 9
2 1
1 2 7 9 11 13 12 20
小结:
两种排序算法
对于排序问题,本节课提供了两种算法,分别是插入排序和合并排序。
插入排序是O(n*n),合并排序是O(nlgn)
其中合并排序运用了递归调用和分治策略,这两个内容将分别在后续两节中介绍。
相关文章推荐
- 插入排序
- 书评:《算法之美( Algorithms to Live By )》
- 选定虚拟主机 性能凸显优势
- 动易2006序列号破解算法公布
- 修改一行代码提升 Postgres 性能 100 倍
- redis的hGetAll函数的性能问题(记Redis那坑人的HGETALL)
- Ruby实现的矩阵连乘算法
- 推荐Sql server一些常见性能问题的解决方法
- C#插入法排序算法实例分析
- SQL Server误区30日谈 第9天 数据库文件收缩不会影响性能
- 和表值函数连接引发的性能问题分析
- SQLServer 2000 升级到 SQLServer 2008 性能之需要注意的地方之一
- 超大数据量存储常用数据库分表分库算法总结
- 数据库性能优化三:程序操作优化提升性能
- C#数据结构与算法揭秘二
- C#冒泡法排序算法实例分析
- VBS中的字符串连接的性能问题
- 算法练习之从String.indexOf的模拟实现开始
- C#算法之关于大牛生小牛的问题
- C#实现的算24点游戏算法实例分析