3.1 Asymptotic notation
Asymptotic efficiency of algorithms: how the running time of an algorithm increases with the size of the input in the limit.Usually, an algorithm that is asymptotically more efficient will be the best choice for all but very small inputs.Θ(g(n)) = {f(n): there exist positive constants c1, c2, and n0 such that 0 c1g(n) f(n) c2g(n) for all n n0}.    /* c1, c2, n0 > 0 */O(g(n)) = {f(n): there exist positive constants c and n0 such that 0 f(n) cg(n) for all n n0}.       /* upper bound */o(g(n)) = {f(n): for any positive constant c > 0, there exists a constant n0 > 0 such that 0 f(n) < cg(n) for all n n0}.          /* upper bound */(g(n)) = {f(n): there exist positive constants c and n0 such that 0 cg(n) f(n) for all n n0}.       /* lower bound */ω(g(n)) = {f(n): for any positive constant c > 0, there exists a constant n0 > 0 such that 0 cg(n) < f(n) for all n n0}.          /* lower bound */Θ-notation: For all values of n to the right of n0, the value of f(n) lies above c1g(n) and below c2g(n). For all n n0, the function f(n) is equal to g(n) to within a constant factor. We say that g(n) is an asymptotically tight bound for f(n).The definition of Θ(g(n)) requires that every member f(n) є Θ(g(n)) be asymptotically positive.We use o-notation to denote an upper bound that is not asymptotically tight.f(n) = Θ(g(n)) implies f(n) = O(g(n)). Θ(g(n)) O(g(n)).For any two functions f(n) and g(n), we have f(n) = Θ(g(n)) if and only if f(n) = O(g(n)) and f(n) = (g(n)).Figure 3.1:Θ, O, and notations

nix 發表在 痞客邦 留言(0) 人氣()


Pseudocode is not typically concerned with issues of software engineering.2.1 Insertion sort
An efficient algorithm for sorting a small number of elements, sorted in place.INSERTION-SORT(A) /* A[1 n], (c1n2) */

nix 發表在 痞客邦 留言(0) 人氣()


    開始念Algorithm了,依照慣例,為了要釐清自己的觀念和讓自己複習及查資料方便,還是在念書的時候盡量整理筆記。Algorithm也是一門非常耐人尋味的學問呢...

1.        The Role of Algorithms in Computing

nix 發表在 痞客邦 留言(0) 人氣()

1
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。