官术网_书友最值得收藏!

Big O notation

The letter "O" in big O notation stands for order, in recognition that rates of growth are defined as the order of a function. We say that one function T(n) is a big O of another function, F(n), and we define this as follows:

The function, g(n), of the input size, n, is based on the observation that for all sufficiently large values of n, g(n) is bounded above by a constant multiple of f(n). The objective is to find the smallest rate of growth that is less than or equal to f(n). We only care what happens at higher values of n. The variable n0represents the threshold below which the rate of growth is not important, The function T(n) represents the tight upper bound F(n). In the following plot we see that T(n) = n2 + 500 = O(n2) with C = 2 and n0 is approximately 23:

You will also see the notation f(n) = O(g(n)). This describes the fact that O(g(n)) is really a set of functions that include all functions with the same or smaller rates of growth than f(n). For example, O(n2) also includes the functions O(n), O(nlogn), and so on.

In the following table, we list the most common growth rates in order from lowest to highest. We sometimes call these growth rates the time complexity of a function, or the complexity class of a function:

主站蜘蛛池模板: 观塘区| 海南省| 黑水县| 铜梁县| 格尔木市| 赣州市| 垫江县| 宁明县| 仲巴县| 屏边| 沙湾县| 华亭县| 杭锦后旗| 阿拉善盟| 澳门| 四会市| 镇康县| 新郑市| 六枝特区| 双桥区| 平度市| 岢岚县| 锡林郭勒盟| 连城县| 甘南县| 九台市| 南澳县| 镇沅| 上思县| 齐齐哈尔市| 阿拉善盟| 西林县| 安吉县| 安宁市| 花莲县| 丽水市| 合水县| 鹿泉市| 富阳市| 万州区| 德昌县|