使用Ө表示法:
如果任何函數具有相同的兩個上限和下限,我們可以使用Ө表示法complexity.Both它的上限和下限可與單數指定來形容它的時間。它只是告訴更多關於功能的特徵。
實施例,
suppose we have a function ,
f(n) = 4logn + loglogn
we can write this function as
f(n) = Ө(logn)
Because its upper bound and lower bound
are O(logn) and Ω(logn) repectively, which are same
so it is legal to write this function as ,
f(n)= Ө(logn)
證明:
**Finding upper bound :**
f(n) = 4logn+loglogn
For all sufficience value of n>=2
4logn <= 4 logn
loglogn <= logn
Thus ,
f(n) = 4logn+loglogn <= 4logn+logn
<= 5logn
= O(logn) // where c1 can be 5 and n0 =2
**Finding lower bound :**
f(n) = 4logn+loglogn
For all sufficience value of n>=2
f(n) = 4logn+loglogn >= logn
Thus, f(n) = Ω(logn) // where c2 can be 1 and n0=2
so ,
f(n) = Ɵ(logn)
類似地,在插入排序的情況下:
If running time of insertion sort is described by simple function f(n).
In particular , if f(n) = 2n^2+n+1 then
Finding upper bound:
for all sufficient large value of n>=1
2n^2<=2n^2 ------------------- (1)
n <=n^2 --------------------(2)
1 <=n^2 --------------------(3)
adding eq 1,2 and 3, we get.
2n^2+n+1<= 2n^2+n^2+n^2
that is
f(n)<= 4n^2
f(n) = O(n^2) where c=4 and n0=1
Finding lower bound:
for all sufficient large value of n>=1
2n^2+n^2+1 >= 2n^2
that is ,
f(n) >= 2n^2
f(n) = Ω(n^2) where c=2 and n0=1
because upper bound and lower bound are same,
f(n) = Ө(n^2)
if f(n)= 2n^2+n+1 then, c1*g(n) and c2*g(n) are presented by diagram:
在最壞的情況下,插入排序上界和下界是爲O(n^2)和Ω(N^2),因此在最壞的情況下是合法的將插入排序的運行寫爲Ө(n^2))
在最好的情況下,它將是Ө(n)。
我投票決定將此視爲「不是真正的問題」,這是SE總結爲的一個條件:「很難說出這裏提出的問題。這個問題不明確,模糊,不完整,過於寬泛或修辭,並且不能按照目前的形式合理地回答。「具體而言,第二段充滿了錯誤信息,整個事情是一個問題,而不是一個問題。 – 2013-03-25 06:15:08
我的問題是,「爲什麼我們使用Ө符號進行插入排序?」我想這可以回答。我在這個問題上寫下了所有的疑問。我想這些懷疑使人懷疑。 – siddstuff 2013-03-25 06:33:02
考慮將編輯移動到新答案並接受答案(是的,您可以回答自己的問題並接受答案)。這樣,你們都可以起來投票並將問題標記爲已回答。 – Shahbaz 2013-04-29 15:47:40