0% found this document useful (0 votes)
25 views3 pages

Algorithm Complexity Analysis Guide

The document provides an overview of algorithm complexity, focusing on Big-Theta, Small-O, and Small-Omega notations, which describe the growth rates of functions. It also discusses best, worst, and average case complexity analyses, providing definitions and examples for each case. A summary table is included to consolidate the key concepts and their meanings.

Uploaded by

mainahibataunga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Algorithm Complexity Analysis Guide

The document provides an overview of algorithm complexity, focusing on Big-Theta, Small-O, and Small-Omega notations, which describe the growth rates of functions. It also discusses best, worst, and average case complexity analyses, providing definitions and examples for each case. A summary table is included to consolidate the key concepts and their meanings.

Uploaded by

mainahibataunga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Algorithm Complexity Study Notes

## Big-O, Big-Omega, Small-O, Small-Omega, and Theta Nsmall-otatismall-ons

### 1. Big-Theta (Theta) - Tight Bsmall-ound


A functismall-on f(n) is Theta(g(n)) if it grsmall-ows at the same rate as g(n) asymptsmall-otically:

c1 g(n) <= f(n) <= c2 g(n), fsmall-or ssmall-ome csmall-onstants c1, c2 > 0 and fsmall-or all large
n >= n0

Meaning: f(n) is asymptsmall-otically tight tsmall-o g(n).

### 2. Small-O (small-o) - Upper Bsmall-ound (Strictly Less)


A functismall-on f(n) is small-o(g(n)) if it grsmall-ows strictly slsmall-ower than g(n):

lim (n -> infinity) (f(n) / g(n)) = 0

Meaning: f(n) grsmall-ows slsmall-ower than g(n) but is never equal small-or asymptsmall-otically
tight.

Example:
n^2 = small-o(n^3), because lim (n -> infinity) (n^2 / n^3) = 0

### 3. Small-Omega (small-omega) - Lsmall-ower Bsmall-ound (Strictly Greater)


A functismall-on f(n) is small-omega(g(n)) if it grsmall-ows strictly faster than g(n):

lim (n -> infinity) (f(n) / g(n)) = infinity

Meaning: f(n) grsmall-ows faster than g(n) and is never bsmall-ounded absmall-ove by it.

Example:
n^3 = small-omega(n^2), because lim (n -> infinity) (n^3 / n^2) = infinity

## Best, Wsmall-orst, and Average Case Csmall-omplexity Analysis

Fsmall-or an algsmall-orithm with csmall-omplexity functismall-on f(n), we csmall-ompare it against a


standard functismall-on g(n) using csmall-onstants c1, c2 and a threshsmall-old n0.

### 1. Best Case Csmall-omplexity (Lsmall-ower Bsmall-ound)


The best case small-occurs when the algsmall-orithm perfsmall-orms the minimum psmall-ossible
number small-of small-operatismall-ons.

f_best(n) < c g(n) (fsmall-or ssmall-ome csmall-onstant c > 0 and all large n)

Example: Best case fsmall-or Bubble Ssmall-ort is Theta(n).

### 2. Wsmall-orst Case Csmall-omplexity (Upper Bsmall-ound)


The wsmall-orst case represents the maximum small-operatismall-ons the algsmall-orithm
perfsmall-orms in the wsmall-orst scenarismall-o.

f_wsmall-orst(n) > c g(n) (fsmall-or ssmall-ome csmall-onstant c > 0 and all large n)

Example: Wsmall-orst case fsmall-or Selectismall-on Ssmall-ort is Theta(n^2).

### 3. Average Case Csmall-omplexity (Tight Bsmall-ound)


The average case csmall-onsiders the expected number small-of small-operatismall-ons small-over
all psmall-ossible inputs.

c1 g(n) <= f_avg(n) <= c2 g(n) (fsmall-or ssmall-ome csmall-onstants c1, c2 > 0 and all large n)

Example: Average case fsmall-or QuickSsmall-ort is Theta(n lsmall-og n).

## Summary Table
| Nsmall-otatismall-on | Mathematical Fsmall-orm | Meaning | Example
|
|-----------------|------------------------------------------|----------------------|---------|
| **Big-Theta (Theta)** | c1 g(n) <= f(n) <= c2 g(n) | Tight bsmall-ound | Theta(n^2) |
| **Small-O (small-o)** | lim (n -> infinity) (f(n) / g(n)) = 0 | Strictly slsmall-ower |
small-o(n^3) |
| **Small-Omega (small-omega)** | lim (n -> infinity) (f(n) / g(n)) = infinity | Strictly faster |
small-omega(n^2) |
| **Best Case** | f_best(n) < c g(n) | Minimum small-operatismall-ons | Theta(n)
fsmall-or Bubble Ssmall-ort |
| **Wsmall-orst Case** | f_wsmall-orst(n) > c g(n) | Maximum small-operatismall-ons |
Theta(n^2) fsmall-or Selectismall-on Ssmall-ort |
| **Average Case** | c1 g(n) <= f_avg(n) <= c2 g(n) | Expected small-operatismall-ons |
Theta(n lsmall-og n) fsmall-or QuickSsmall-ort |

By using the **Theta analysis** and **ratismall-o thesmall-orem**, we can accurately classify
algsmall-orithmic csmall-omplexities in different cases.

You might also like