Week1-9Order-of-Growth classifications
来源:互联网 发布:linux内核开发工程师 编辑:程序博客网 时间:2024/06/05 00:31
Common Order-of-Growth classifications
Small set of functions
1,logN,N,NlogN,N2,N3,abN
linearithmic and linear scale with the input size!!
Binary Search
Implementation
public static int binarySearch( int[] a, int key ){ int lo = 0, hi = a.length - 1; while( lo <= hi ) { int mid = ( hi + lo ) / 2; if( key < a[mid] ) { hi = mid - 1; } if( key > a[mid] ) { lo = mid + 1; } else return mid; } return -1;}
Mathematical Analysis
Proposition
BS uses at most
1+logN compares to search in a sorted array of sizeN
Def
T(N)=# compares to BS in a sorted subarray of size≤N
BS in recurrence:
T(N)≤logN+1
An N2logN algorithm for 3-SUM
- Sort the N distinct numbers
- For each pair of numbers a[i] and a[j], binary search for -(a[i] + a[j])
Guiding Principle
Typically, better order of growth = faster in practice
0 0
- Week1-9Order-of-Growth classifications
- SICP ex1-10 order of Growth
- [小总结]常见order-of growth
- 6.00 Introduction to Computer Science and Programming Lec 8: Efficiency and Order of Growth
- Chapter3 Growth of Functions
- Growth of a Population
- week1-10Theory of algorithms
- Week1-2Examples of text
- The Growth Markets of China
- week1
- week1
- week1
- week1
- week1
- week1
- Does One-Against-All or One-Against-One Improve the Performance of Multiclass Classifications?
- Week1-6Analysis of Algorithm Introduction
- growth
- 将数组进行k个数的倒转,算法效率优先
- C++,传递多个参数
- 数组变量的越界特征
- 机房—账房先生现身结账
- 〝女人旺夫的秘密〞女人应该看 男人更应该看!
- Week1-9Order-of-Growth classifications
- 《剑指offer》把字符串转换成整数
- 2015华为机试题
- 技能表
- 高效程序员的7个共同特征
- servlet配置文件
- LeetCode 2 Add Two Numbers
- 强弩之末,不能入鲁缟;冲风之衰,不能起毛羽。
- 提升程序员生产力的10个技巧