Complexity
Last updated
Last updated
分析演算法好壞取決於不同角度:
時間複雜度(Time Complexity )
空間複雜度(Space Complexity)
當 n 越大的時候的函數趨勢:
An algorithm is said to be of polynomial time if its running time is upper bounded by a polynomial expression in the size of the input for the algorithm. ex,
時間複雜度不能被 Polynomial function bound 住的,
NO! 這個問題的關鍵在於 n 的大小,當 n 極大或是超過某個 n0 後,前者會呈指數上升,但是如果 n 極小的話, 前者是有可能較快的
example: ,則 都是前者較快
一個演算法的 Upper-bound 取決於 worst case running time.
Theory of Computation
f(n) = Ω(g(n)) <-> g(n) = O(f(n))
存在正數,使得對於所有, 都符合 的集合
,includes all functions that are upper bounded by
存在正數,使得對於所有, 都符合 的集合
,includes all functions that are lower bounded by