Slide 3
Slide 3
► Greedy Algorithm always makes the choice (greedy criteria) looks best at the
moment, to optimize a given objective.
► The greedy algorithm doesn't always guarantee the optimal solution however
it generally produces a solution that is very close in value to the optimal.
Continued…
► For Example:
1. 1. 3n+2=O(n) as 3n+2≤4n for all n≥2
2. 2. 3n+3=O(n) as 3n+3≤4n for all n≥3
► Hence, the complexity of f(n) can be represented as O (g (n))
Continued…
► For Example:
► f (n) =8n2+2n-3≥8n2-3
► =7n2+(n2-3)≥7n2 (g(n))
► Thus, k1=7
► Hence, the complexity of f (n) can be represented as Ω (g (n))
Continued…
► 3. Theta (θ): The function f (n) = θ (g (n)) [read as "f is the theta of g of
n"] if and only if there exists positive constant k1, k2 and k0 such that
► k1 * g (n) ≤ f(n)≤ k2 g(n)for all n, n≥ n0
Continued…
Continued…
► The Theta Notation is more precise than both the big-oh and Omega notation.
The function f (n) = θ (g (n)) if g(n) is both an upper and lower bound.
?