使用Ө表示法:
如果任何函数具有相同的两个上限和下限,我们可以使用Ө表示法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