PHP开发人员喜欢使用 Laravel 的 7 个主要原因
先决条件 - 渐近符号,渐近符号的属性,算法分析
1.大哦符号(O):
它被定义为算法的上限,算法的上限是所需的最多时间(最坏情况下的性能)。
大哦符号用于描述渐近上界。
在数学上,如果f(n)描述了一个算法的运行时间; f(n)是O(g(n))如果存在正常数C和n0使得,
0 <= f(n) <= Cg(n) for all n >= n0
n = 用于给出一个函数的上限。
如果一个函数是O(n) ,它也自动是O(n-square) 。
Big oh (O) 的图形示例:
2.大欧米茄符号(Ω):
它被定义为算法的下限,并且算法的下限是所需的最少时间(可能是最有效的方式,换句话说就是最好的情况)。
就像O表示法提供渐近上界一样, Ω表示法提供渐近下界。
让f(n)定义算法的运行时间;
如果存在正常数C和(n0) ,则称f(n)为Ω(g (n)) ,使得
0 <= Cg(n) <= f(n) for all n >= n0
n = 用于给定函数的下限
如果一个函数是Ω(n-square) ,它也自动是Ω(n) 。
Big Omega (Ω) 的图形示例:
3. 大 Theta 符号 (Θ):
它被定义为最紧密的界限,最紧密的界限是算法可以采用的所有最坏情况时间中最好的时间。
让f(n)定义算法的运行时间。
如果f(n)为O(g(n))且f(n)为Ω(g(n)),则称 f(n) 为 Θ(g(n) ) 。
Mathematically,
0 <= f(n) <= C1g(n) for n >= n0
0 <= C2g(n) <= f(n) for n >= n0
Merging both the equation, we get :
0 <= C2g(n) <= f(n) <= C1g(n) for n >= n0
该等式仅表示存在正常数 C1 和 C2,使得 f(n) 夹在 C2 g(n) 和 C1g(n) 之间。 Big Theta (Θ)的图形示例:
Big oh、Big Omega 和 Big Theta 之间的区别: S.No.Big Oh (O) Big Omega (Ω) Big Theta (Θ) 1. It is like (<=)
rate of growth of an algorithm is less than or equal to a specific value. It is like (>=)
rate of growth is greater than or equal to a specified value.It is like (==)
meaning the rate of growth is equal to a specified value.2. The upper bound of algorithm is represented by Big O notation. Only the above function is bounded by Big O. asymptotic upper bond is it given by Big O notation. The algorithm’s lower bound is represented by Omega notation. The asymptotic lower bond is given by Omega notation. The bounding of function from above and below is represented by theta notation. The exact asymptotic behavior is done by this theta notation. 3. Big oh (O) – Upper Bound Big Omega (Ω) – Lower Bound Big Theta (Θ) – Tight Bound 4. It is define as upper bound and upper bound on an algorithm is the most amount of time required ( the worst case performance). It is define as lower bound and lower bound on an algorithm is the least amount of time required ( the most efficient way possible, in other words best case). It is define as tightest bound and tightest bound is the best of all the worst case times that the algorithm can take. 5. Mathematically: Big Oh is 0 <= f(n) <= Cg(n) for all n >= n0 Mathematically: Big Omega is 0 <= Cg(n) <= f(n) for all n >= n0 Mathematically – Big Theta is 0 <= C2g(n) <= f(n) <= C1g(n) for n >= n0