zoukankan      html  css  js  c++  java
  • What is the difference between Θ(n) and O(n)?

    Short explanation:

    If an algorithm is of Θ(g(n)), it means that the running time of the algorithm as n (input size) gets larger is proportional to g(n).

    If an algorithm is of O(g(n)), it means that the running time of the algorithm as n gets larger is at most proportional to g(n).

    Normally, even when people talk about O(g(n)) they actually mean Θ(g(n)) but technically, there is a difference.

    More technically:

    O(n) represents upper bound. Θ(n) means tight bound. Ω(n) represents lower bound.

    Big O means your algorithm will execute in no more steps than in given expression asymptotically (like n^2)

    Big Omega means your algorithm will execute in no fewer steps than in the given expression asymptotically (like n^2)

    When both condition are true for the same expression, you can use the big theta notation....

    f(x) = Θ(g(x)) iff f(x) = O(g(x)) and f(x) = Ω(g(x))

    Basically when we say an algorithm is of O(n), it's also O(n2), O(n1000000), O(2n), ... but a Θ(n) algorithm is not Θ(n2).

  • 相关阅读:
    bfs两种记录路径方法
    次小生成树
    2018 ICPC 区域赛 焦作场 D. Keiichi Tsuchiya the Drift King(计算几何)
    数组分组
    POJ
    数位DP详解
    2018ICPC青岛 E
    HDU
    Google工程师打造Remix OS系统 桌面版安卓下载
    使用angular封装echarts
  • 原文地址:https://www.cnblogs.com/JasperZhao/p/13864644.html
Copyright © 2011-2022 走看看