You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Big O符号相关技术咨询:命题真伪判断及是否符合传递性规则

Hey there! Let's work through your questions clearly since you're just diving into Big O notation—totally normal to hit these confusion points early on!

1. Is the proposition "If g = O(f) and h = O(f), then g = O(h)" valid?

Short answer: No, this proposition does not hold in general.

To understand why, let's start with the formal definition of Big O notation:

A function ( g(n) ) is said to be ( O(f(n)) ) if there exist constants ( C > 0 ) and ( n_0 \geq 0 ) such that for all ( n \geq n_0 ), ( |g(n)| \leq C \cdot |f(n)| ). In plain terms, ( g ) grows no faster than a constant multiple of ( f ) as ( n ) gets very large.

Now let's use a concrete counterexample to disprove the proposition:

  • Let ( f(n) = n ) (linear growth)
  • Let ( g(n) = n ) (also linear)
  • Let ( h(n) = 1 ) (constant growth)

First, check the premises:

  • ( g(n) = n ) is ( O(f(n)) ): Pick ( C=1 ) and ( n_0=1 )—for all ( n \geq 1 ), ( n \leq 1 \cdot n ), which is true.
  • ( h(n) = 1 ) is ( O(f(n)) ): Pick ( C=1 ) and ( n_0=1 )—for all ( n \geq 1 ), ( 1 \leq 1 \cdot n ), which is also true.

Now check the conclusion: Is ( g(n) = n ) ( O(h(n)) = O(1) )?
For ( n ) to be ( O(1) ), we'd need some constant ( C ) where ( n \leq C \cdot 1 ) for all sufficiently large ( n ). But as ( n ) grows, it will always exceed any fixed ( C )—so this is impossible.

This counterexample shows the proposition fails: even though both ( g ) and ( h ) are upper-bounded by ( f ), ( g ) can grow much faster than ( h ), making ( g = O(h) ) false.

2. Does this proposition follow Big O's transitivity?

No, it does not—this proposition is unrelated to Big O's transitive property, and in fact, it contradicts how transitivity works.

Big O's transitivity is a well-established rule that says:

If ( a = O(b) ) and ( b = O(c) ), then ( a = O(c) ).

This is a "chain" relationship: ( a ) is bounded by ( b ), which is bounded by ( c ), so ( a ) must be bounded by ( c ). Your proposition, however, is a "fork" relationship: both ( g ) and ( h ) are bounded by ( f ), but there's no chain linking ( g ) to ( h ) through ( f ). Transitivity doesn't apply here, as we saw with the counterexample above.

Quick recap to solidify

  • Big O describes an asymptotic upper bound, not a direct comparison between every pair of functions that share a common upper bound.
  • Transitivity only applies when you have a sequence of bounded functions (A → B → C), not when two functions both bound to a third (A ← C → B).

内容的提问来源于stack exchange,提问作者Marrykittens

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 21:13:09