Docsity

Order Notation in Computer Science: Theta, Big O, Omega, and Other Notations, Study notes of Algorithms and Programming

Toggle sidebar
bg1
Chapter 3: Order Notation
Θ, O, Ω, o, ω, ⌊,⌋,⌈,⌉,log,lg,ln,!,P,Q
Asymptotic Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Order Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Order Notation Continued. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
More Notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
More Notation Continued . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Log-Log Plot of Some Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Summation Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Some Miscellaneous Stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1
Asymptotic Behavior
Let f(n)and g(n)be nonnegative functions when n≥0.
Define f(n)≺g(n)
(read “f(n)is asymptotically less than g(n)”)
if there exists a positive constant ksuch that
f(n)< g(n)when n≥k.
(This definition is not in the book.)
Examples:
2n+ 100 ≺3n−100 (consider n≥200)
1000n2≺2n/1000 (consider n≥30)
Θ(g(n)) includes all functions bounded by constant factors of g(n).
CS 5633 Analysis of Algorithms Chapter 3: Slide – 2
Order Notation
Theta-notation:
f(n)∈Θ(g(n)) if c1g(n)≺f(n)≺c2g(n)
for some positive constants c1and c2.
Big-Oh-notation:
f(n)∈O(g(n)) if f(n)≺c g(n)
for some positive constant c.
Big-Omega-notation:
f(n)∈Ω(g(n)) if c g(n)≺f(n)
for some positive constant c.
little-oh-notation:
f(n)∈o(g(n)) if f(n)≺c g(n)
for all positive constants c.
CS 5633 Analysis of Algorithms Chapter 3: Slide – 3
2
pf2

Partial preview of the text

Download Order Notation in Computer Science: Theta, Big O, Omega, and Other Notations and more Study notes Algorithms and Programming in PDF only on Docsity!

Chapter 3: Order Notation^ Θ, O,^ Ω

, o, ω,^ ⌊,^ ⌋,^ ⌈

,^ ⌉,^ log,^ lg,^ ln

∑∏, !, ,^

Asymptotic Behavior........................................ 2Order Notation............................................ 3Order Notation Continued..................................... 4More Notation............................................. 5More Notation Continued..................................... 6Log-Log Plot of Some Functions................................ 7Summation Notation........................................ 8Some Miscellaneous Stuff..................................... 9

Asymptotic Behavior ^ Let^ f^ (n)^

and^ g(n)^ be nonnegative functions when

n^ ≥^0.

^ Define^ f^ (

n)^ ≺^ g(n) (read “f (n)^ is asymptotically less than

g(n)”)

if there exists a positive constant

k^ such that f^ (n)^ < g(n)^

when^ n^ ≥^ k. (This definition is not in the book.)  Examples: 2 n^ + 100^ ≺^3

n^ −^100 (consider

n^ ≥^200 ) 2 n 1000 n≺^2 / 1000 (consider

n^ ≥^30 ) ^ Θ(g(n))^ includes all functions bounded by constant factors of

g(n).

CS 5633 Analysis of Algorithms

Chapter 3: Slide – 2

Order Notation ^ Theta-notation:^ f^ (n)^ ∈^ Θ(

g(n))^ if^ cg(^1

n)^ ≺^ f^ (n)^ ≺

cg(n)^2 for some positive constants

cand^ c.^1 ^ Big-Oh-notation:^ f^ (n)^ ∈^ O

(g(n))^ if^ f^ (n

)^ ≺^ c g(n) for some positive constant

c. ^ Big-Omega-notation:^ f^ (n)^ ∈^ Ω(

g(n))^ if^ c g(n

)^ ≺^ f^ (n) for some positive constant

c. ^ little-oh-notation:^ f^ (n)^ ∈^ o(

g(n))^ if^ f^ (n)

≺^ c g(n) for all positive constants

c. CS 5633 Analysis of Algorithms

Chapter 3: Slide – 3 2

Order Notation Continued ^ little-omega-notation:^ f^ (n)^ ∈^ ω

(g(n))^ if^ c g(

n)^ ≺^ f^ (n) for all positive constants

c. If^ f^ (n)^ is^ f

(n)^ also^.. .? is...^ o(g

(n))^ O(g(n)) Θ(

g(n)) Ω(g(n))

ω(g(n))

o(g(n)) O(g(n)) Θ(g(n)) Ω(g(n)) ω(g(n)) CS 5633 Analysis of Algorithms

Chapter 3: Slide – 4

More Notation f^ (n)^ is^...^

if^... monotonically increasing

m^ ≤^ n^ →^

f^ (m)^ ≤^ f^ (n) monotonically decreasing

m^ ≤^ n^ →^

f^ (m)^ ≥^ f^ (n) strictly increasing

m < n

→^ f^ (m)^ < f

(n)

strictly decreasing

m < n

→^ f^ (m)^ > f

(n)

^ ⌊x⌋^ is the floor of

x.^ ⌈x⌉^ is the ceiling of

x.

di^ ^ anis polynomial in Σi^ i=

n^ of degree^

d. n^  ais exponential in

n. logn^ is logarithmic ina^

n. CS 5633 Analysis of Algorithms

Chapter 3: Slide – 5

More Notation Continued ^ Also,^ loga

lognb^ n = logab^ lg n = logn (^2) ln n = logn where^ e^ = 2e

.^71828 · · ·

^ n!^ is^ n^ factorial. ^ Let^0 < a <

1 < b < c.a Θ(1) ≺ Θ(lg^ n)^ ≺^ Θ(n)

≺^ Θ(n)^ ≺^ Θ(

n^ lg^ n)^ ≺^ Θ(n

bc)^ ≺^ Θ(n)^ ≺

n Θ(b)^ ≺^ Θ(c n)^ ≺^ Θ(n!)^ ≺

n Θ(n) CS 5633 Analysis of Algorithms

Chapter 3: Slide – 6 3

Log-Log Plot of Some Functions^ 1e+09^ 1e+08^ 1e+07^ 1e+06^1000001000010001001011

10

100 T(N)

N^N fact(N)^ 3^N^ 2^N^ N^3^ N^2 N*lg(N)^ N sqrt(N) lg(N) N CS 5633 Analysis of Algorithms

Chapter 3: Slide – 7

Summation Notation^ n ^ a=^ a^ Σi^ i=

+^ a+^ · · ·^ + 1 2 an n ^ c a=^ Σi^ i= nc a Σi i= n ^ (a+^ b Σi^ i=

n) = a+^ Σii^ i= n^ b Σi i= ^ If^ a, a,... , a^12

is increasing, then:n n^ ais^ O^ (n a Σi^ i=

)n ( n ais Ω n a Σi (^) i= ) n/ 2 CS 5633 Analysis of Algorithms

Chapter 3: Slide – 8

Some Miscellaneous Stuff^ n ^ a=^ a^ Πi^ i=

a· · ·^ a 1 2 n (^ n  log^ Πb^ i= )n a^ =^ (log^ Σi^ i=

a)b i ^ Sets, Relations, Functions, Graphs, TreesSee Appendix B CS 5633 Analysis of Algorithms

Chapter 3: Slide – 9 4