码迷,mamicode.com
首页 > 编程语言 > 详细

【听课笔记】算法导论

时间:2015-07-25 19:46:05      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

课程地址

http://v.163.com/special/opencourse/algorithms.html

今天课程地址:

http://open.163.com/movie/2010/12/G/F/M6UTT5U0I_M6V2T1JGF.html

讨论performance

Analysis of Algorithms: the study of computer program performance ans resource usage.

Thinking: What is more important than performance?

Functionality, modularity, user-friendliness, security...

Then why study algs and perf?

performance is like the "money", you can buy other stuff...这个有点不懂,讨论一下

 

Problem sorting

Insertion sort

每次保证在第i位置之前的都是sort好的

8 2 4 9 3 6  i = 1

2 8 4 9 3 6  i = 2

2 4 8 9 3 6  i = 3

2 4 8 9 3 6  i = 4

2 3 4 8 9 6  i = 5

2 3 4 6 8 9  done

Running time analysis

  • Depends on input (best case, wrost case)
  • Depends on input size

wrost case, ave case, best case

BIG IDEA: Asymptotc analysis 渐进分析

  • Ignore machine dependent
  • Look at the growth

Θ notation, 比的是n在无限大时的情况~所以n^2肯定比n^3快哒。

Wrost case:

Θ(n^2)

 

Merge sort A[1,..., n]

1, if n =1, done

2, recursively sort A[1,..., n/2] and A[n/2 + 1, ..., n]

3, merge 2 sorted lists

T(n) = 2T(n/2) + Θ(n) if n > 1

T(n) = cn*lgn + Θ(n) = Θ(nlgn)   c代表常数

 

【听课笔记】算法导论

标签:

原文地址:http://www.cnblogs.com/wnan42/p/4676202.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!