Asymptotic-Notation-

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Asymptotic Notation, Review of Functions &
Summations
28 Aug 2003
Asymptotic Complexity
Running time of an algorithm as a function of input size n for large n.
10n2 - 3n = Q(n2) What constants for n0, c1, and c2 will work? Make c1 a little smaller than the leading
coefficient, and c2 a little bigger. To compare orders of growth, look at the
}
Intuitively: Set of all functions that have the same rate of growth as g(n).
g(n) is an asymptotically tight bound for any f(n) in the set.
asymp - 3
Q-notatotation
lgn, n, n2, n3, …
For function g(n), we define Q(g(n)), big-Theta of n, as the set:
Q(g(n)) = {f(n) :
positive constants c1, c2, and n0, such that n n0, we have 0 c1g(n) f(n) c2g(n)
Ex: f(n) = Q(n2). Describes how f(n) grows in comparison to n2. Define a set of functions; in practice used to compare two function values. The notations describe different rate-of-growth relations between the defining function and the defined set of functions.
For function g(n), we define Q(g(n)), big-Theta of n, as the set:
Q(g(n)) = {f(n) :
positive constants c1, c2, and n0, such that n n0, we have 0 c1g(n) f(n) c2g(n)
}
Technically, f(n) Q(g(n)). Older usage, f(n) = Q(g(n)). I’ll accept either…
f(n) and g(n) are nonnegative, for large n.
asymp - 4
Example
Q(g(n)) = {f(n) : positive constants c1, c2, and n0, such that n n0, 0 c1g(n) f(n) c2g(n)}
Any linear function an + b is in O(n2). How? Show that 3n3 = O(n4) for appropriate c and n0. Show that 3n3 = O(n3) for appropriate c and n0.
Expressed using only the highest-order term in the expression for the exact running time.
Instead of exact running time, we use asymptotic notations such as O(n), Q(n2), Ω(n).
leading term (highest-order term). Exercise: Prove that n2/2-3n= Q(n2)
asymp - 5
Example
Q(g(n)) = {f(n) : positive constants c1, c2, and n0, such that n n0, 0 c1g(n) f(n) c2g(n)}
we have 0 f(n) cg(n) }
Intuitively: Set of all functions whose rate of growth is the same as or lower than that of g(n).
g(n) is an asymptotic upper bound for any f(n) in the set.
Describes behavior of running time functions by setting lower and upper bounds for their values.
asymp - 1
Asymptotic Notation
Q, O, W, o, w Defined for functions over the natural numbers.
f(n) = Q(g(n)) f(n) = O(g(n)). Q(g(n)) O(g(n)).
asymp - 7
Examples
O(g(n)) = {f(n) : positive constants c and n0, such that n n0, we have 0 f(n) cg(n) }
Is 3n3 Q(n4) ? How about 22n Q(2n)?
asymp - 6
O-notation
For function g(n), we define O(g(n)), big-O of n, as the set:
O(g(n)) = {f(n) :
positive constants c and n0, such that n n0,
相关文档
最新文档