程序猿的读书笔记

2.5 O-Notation

2017-01-11  本文已影响0人  綿綿_

The "O" is for order,as in "Binary search is O(logn);it takes on the order of logn steps to search an array of n items. "
The notation O (f(n)) means that once n gets large ,the running time is proportional to at most f(n), for example , O(n2) or O(nlogn).

Notation Name Example
O(1) constant array index
O(logn) logarithmic binary search
O(n) linear string comparison
O(nlogn) nlogn quick sort
O(n2) quadratic simple sorting methods
O(n3) cubic matrix multiplication
O(2n) exponential set partitioning
上一篇 下一篇

猜你喜欢

热点阅读