[英]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:允许负函数使等价定义复杂化,实际上使它们不等价:
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 > N
: f(n)
f(n) <= C*g(n)
O(g(n))
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) < infinity
当n->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.