简体   繁体   English

为什么在定义 Θ 时 f(n) 和 g(n) 需要为非负 function

[英]Why does f(n) and g(n) needs to be non-negative function while defining Θ

While reading about Θ definition in CLRS.在阅读 CLRS 中的 Θ 定义时。 I found我发现

The definition of Θ(g(n)) requires that every member f(n) ∈ Θ(g(n))  be
asymptotically nonnegative, that is, that f(n) be nonnegative whenever n is 
sufficiently large. Consequently, the function g(n) itself must be 
asymptotically nonnegative, or else the set Θ(g(n))  **is empty.** 

Having one positive function and other being the negative, can possibly not let us do asymptotic analysis.(Θ(g(n)) can be a empty set here).有一个正的 function 和另一个是负的,可能不能让我们做渐近分析。(Θ(g(n))在这里可以是一个空集)。

But

In case where both functions are negative shouldn't be a problem and will count to a valid analysis.如果两个函数都是负数,这不应该是一个问题,并将计入有效分析。 Why does author put such restriction on the Θ.为什么作者对Θ施加这样的限制。 Is this useless?这没用吗?

Allowing negative functions is complicating the equivalent definitions, and in fact making them non equivalent:允许负函数使等价定义复杂化,实际上使它们不等价:

  1. f(n) is in O(g(n)) if there are constants N,C such that for all n > N : f(n) <= C*g(n)如果存在常数N,C使得对于所有n > Nf(n) f(n) <= C*g(n) O(g(n))
  2. f(n) is in O(g(n)) if limsup f(n)/g(n) < infinity when n->infinity f(n)O(g(n))如果limsup f(n)/g(n) < infinityn->infinity

And let's look at two asymptotically negative functions.让我们看看两个渐近负函数。

f(n) = -(n^2)
g(n) = -n

According to definition 1:根据定义1:

for all n > 2, and with constant 1:
-(n^2) <= 1*-n 
And thus -(n^2) is in O(-n)

According to definition 2:根据定义 2:

limsup -(n^2) / -n = n = infinity    when  n -> infinity
So, -(n^2) is not in O(-n)

bottom line: This definition removes this complication, while not losing any usefulness for the big O notation usefulness to analyze algorithms, which is the main focus of the book.底线:这个定义消除了这种复杂性,同时又不失大 O 符号对分析算法的有用性,这是本书的主要重点。

(To be clear, this probably could have been solved with clever definitions workarounds, but this just complicates things unnecessarily, which the author probably wanted to avoid). (需要明确的是,这可能可以通过巧妙的定义变通办法来解决,但这只会使事情变得不必要地复杂化,作者可能想避免这种情况)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 鉴于 f(n) = 10000000n 和 g(n) = n^2。 为什么 f(n) 是 O(g(n))? - Given that f(n) = 10000000n and g(n) = n^2. Why f(n) is O(g(n))? 如果 f(n) = Θ(g(n)) f(n) 是否渐近地等于 g(n)? - If f(n) = Θ(g(n)) does that f(n) is asymptotically equal to g(n)? 对于整数A&gt; 0,B&gt; 0,N&gt; 0,找到整数x&gt; 0,y&gt; 0,使得N-(Ax + By)是最小的非负 - For integers A>0, B>0, N>0, find integers x>0,y>0 such that N-(Ax+By) is smallest non-negative 如果f(n)为O(g(n)),则f(n)渐近地增长不快于g(n)吗? - If f(n) is O(g(n)), does f(n) grow asymptotically no faster than g(n)? 渐近。 如果 f(n) = theta(g(n)) 并且 g(n) = theta(h(n)),那么为什么 h(n) = theta(f(n)) - Asymptotic. If f(n) = theta(g(n)) and g(n) = theta(h(n)), then why h(n) = theta(f(n)) "证明 f(n) = Θ(g(n)) 当且仅当 g(n) = Θ(f(n))" - Prove that f(n) = Θ(g(n)) iff g(n) = Θ(f(n)) f(n) = o(g(n)) ve f(n) ≠ Ɵ(g(n)) - f(n) = o(g(n)) ve f(n) ≠ Ɵ(g(n)) 在g(n)之前排列f(n)是什么意思? - What does it mean to arrange f(n) before g(n)? 查找所有与n相加的k个非负整数的唯一集合 - Find all unique sets of k non-negative integers summing to n 非负加权网格中从单个源到单个目标的最短路径(n,5) - shortest path from single source to single destination in a non-negative weighted grid (n,5)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM