iT邦幫忙

2024 iThome 鐵人賽

DAY 5
0
佛心分享-IT 人自學之術

演算法與資料結構入門:30天基礎學習之旅系列 第 5

Understanding Big Θ (Theta) and Big Ω (Omega) in Asymptotic Notations-day 5

  • 分享至 

  • xImage
  •  

上篇提到 Big O Notation
我們現在知道了 Big O 用來表示演算法的 upper bound / worst case scenario(上界限 / 最壞情況)
這篇介紹 Asymptotic Notations (漸進符號),也就是 Big O 其背後的基本概念

Asymptotic Notations 漸進符號

Asymptotic notation helps us describe the efficiency of an algorithm by focusing only on the most significiant factors that impact its performance. It ignores constant factors and lower-order terms, allowing us to concentrate on how the algorithm scales as the input size grows.

漸進符號的意思就是,只關注影響演算法效率中最重要的部分,忽略常數因子低階數項

upper bound & lower bound

Big Θ(Theta)

The Big Theta combination with Big O(upper bound) & Big Omega(lower bound)

Big Θ(Theta) 描述了由 Big O (upper bound)與 Big Ω (lower bound)組合而成的區間,表示該演算法最佳情況不會低於某值,但最糟情況也不會高於某值

This notation describes BOTH the upper and lower bound of a function and is often referred to as the average time complexity.

E.g
if an algorithm's time complexity is Θ(n), it means that

  • The algorithm will not take more than O(n) time (upper bound).
  • It will also not take less than Ω(n) time (lower bound).

Big Ω(Omega)

Describes the lower bound on the time complexity, or the best-case scenario.
若想知道此f(n)最少需耗費多少時間,用 Big Ω來取得此 f(n) 的 lower bound


還意猶未盡的話可以看這裡 關於 Big O & Big Omega 的正式定義

definition of Big O

Definition Big–O, O()): Let f(n) and g(n) be functions that map positive integers to positive real
numbers. We say that f(n) is O(g(n)) (or f(n) ∈ O(g(n))) if there exists a real constant c > 0 and there
exists an integer constant n0 ≥ 1 such that f(n) ≤ c ∗ g(n) for every integer n ≥ n0.

definition of Big Omega

Definition (Big–Omega, Ω()): Let f(n) and g(n) be functions that map positive integers to positive
real numbers. We say that f(n) is Ω(g(n)) (or f(n) ∈ Ω(g(n))) if there exists a real constant c > 0 and
there exists an integer constant n0 ≥ 1 such that f(n) ≥ c · g(n) for every integer n ≥ n0.

相關資源

Asymptotic Notations 101: Big O, Big Omega, & Theta (Asymptotic Analysis Bootcamp)
https://youtu.be/0oDAlMwTrLo?si=c_EKSIySGhJ37J68
Asymptotic notation
https://www.khanacademy.org/computing/computer-science/algorithms/asymptotic-notation/a/asymptotic-notation
Complexity:Asymptotic Notation(漸進符號)
https://alrightchiu.github.io/SecondRound/complexityasymptotic-notationjian-jin-fu-hao.html#an
Asymptotic notation
https://www.khanacademy.org/computing/computer-science/algorithms/asymptotic-notation/a/asymptotic-notation
A Guide to Understanding Big-O, Big-Ω and Big-ϴ Notation
https://medium.com/@alejandro.itoaramendia/a-guide-to-understanding-big-o-big-%CF%89-and-big-%CE%B8-notation-7c407a6824d9
https://csbabel.wordpress.com/2009/05/20/an-intro-to-big-o-omega-theta-notation-and-big-oo/


上一篇
common types of time complexities in big O-day4
下一篇
Introduction to Linear Search(Sequential Search)-day6
系列文
演算法與資料結構入門:30天基礎學習之旅30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言