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).

  • 相关阅读:
    day08 服务
    day11
    day09
    day10 多媒体(文字 图片 音频 视频)
    注意事项
    自己的memcache类
    memcache安装
    android的init过程分析
    Android.mk文件语法规范及使用模板
    【转】基于V4L2的视频驱动开发
  • 原文地址:https://www.cnblogs.com/JasperZhao/p/13864644.html
Copyright © 2011-2022 走看看