In this article, we will discuss some examples on asymptotic notation and mathematics behind it.

## Finding upper bound

Upper bound of any function is defined as follow:

Let f(n) and g(n) are two nonnegative functions indicating the running time of two algorithms. We say, g(n) is upper bound of f(n) if there exist some positive constants c and n

_{0}such that 0 â‰¤ f(n) â‰¤ c.g(n) for all n â‰¥ n_{0}. It is denoted as f(n) = ÎŸ(g(n)).

### Examples on Upper Bound Asymptotic Notation

**Example:** Find upper bound of running time of constant function f(n) = 6993.

To find the upper bound of f(n), we have to find c and n_{0}Â such that 0 â‰¤ f (n) â‰¤ c.g(n) for all n â‰¥ n_{0}

0 â‰¤ f (n) â‰¤ c Ã— g (n)

0 â‰¤ 6993 â‰¤ c Ã— g (n)

0 â‰¤ 6993 â‰¤ 6993 x 1

So, c = 6993 and g(n) = 1

Any value of c which is greater than 6993, satisfies the above inequalities, so all such values of c are possible.

0 â‰¤ 6993 â‰¤ 8000 x 1 â†’ true

0 â‰¤ 6993 â‰¤ 10500 x 1 â†’ true

Function f(n) is constant, so it does not depend on problem size n. So n_{0}= 1

f(n) = O(g(n)) = O(1) for c = 6993, n_{0}Â = 1

f(n) = O(g(n)) = O(1) for c = 8000, n_{0}Â = 1Â and so on.

**Example:** Find upper bound of running time of a linear function f(n) = 6n + 3.

To find upper bound of f(n), we have to find c and n_{0} such that 0 â‰¤ f (n) â‰¤ c Ã— g (n) for all n â‰¥ n_{0}

0 â‰¤ f (n) â‰¤ c Ã— g (n)

0 â‰¤ 6n + 3 â‰¤ c Ã— g (n)

0 â‰¤ 6n + 3 â‰¤ 6n + 3n, for all n â‰¥ 1 (There can be such infinite possibilities)

0 â‰¤ 6n + 3 â‰¤ 9n

So, c = 9 and g (n) = n, n_{0} = 1

**Tabular Approach**

0 â‰¤ 6n + 3 â‰¤ c Ã— g (n)

0 â‰¤ 6n + 3 â‰¤ 7 n

Now, manually find out the proper n_{0}, such that f (n) â‰¤ c.g (n)

n | f(n) = 6n + 3 | c.g(n) = 7n |

1 | 9 | 7 |

2 | 15 | 14 |

3 | 21 | 21 |

4 | 27 | 28 |

5 | 33 | 35 |

From Table, for n â‰¥ 3, f (n) â‰¤ c Ã— g (n) holds true. So, c = 7, g(n) = n and n_{0} = 3, There can be such multiple pair of (c, n_{0})

f(n) = O(g(n)) = O(n) for c = 9, n_{0}Â = 1

f(n) = O(g(n)) = O(n) for c = 7, n_{0}Â = 3

and so on.

**Example: **Find upper bound of running time of quadratic function f(n) = 3n^{2} + 2n + 4.

To find upper bound of f(n), we have to find c and n_{0} such that 0 â‰¤ f (n) â‰¤ c Ã— g (n) for all n â‰¥ n_{0}

0 â‰¤ f (n) â‰¤ c Ã— g (n)

0 â‰¤ 3n^{2}Â + 2n + 4 â‰¤ c Ã— g (n)

0 â‰¤ 3n^{2}Â + 2n + 4 â‰¤ 3n^{2 }+ 2n^{2}Â + 4n^{2},Â

for allÂ n Â Â â‰¥ Â 1:

0 â‰¤Â 3n^{2}Â + 2n + 4 â‰¤ 9n^{2}

0 â‰¤ 3n^{2}Â +2n + 4 â‰¤ 9n^{2}

So, c = 9,Â g(n) = n^{2}Â andÂ n_{0}Â = 1

**Tabular approach**:

0 â‰¤ 3n^{2}Â + 2n + 4 â‰¤Â c.g (n)

0 â‰¤ 3n^{2 }+ 2n + 4 â‰¤ 4n^{2}

Now, manually find out the proper n_{0}, such that f(n) â‰¤ c.g(n)

n | f(n) = 3n^{2} + 2n + 4 | c.g (n) = 4n^{2} |

1 | 9 | 4 |

2 | 20 | 16 |

3 | 37 | 36 |

4 | 60 | 64 |

5 | 89 | 100 |

From Table, for n â‰¥ 4, f(n) â‰¤ c Ã— g (n) holds true. So, c = 4, g(n) = n^{2} and n_{0} = 4. There can be such multiple pair of (c, n_{0})

f(n) = O (g(n)) = O (n^{2})Â for c = 9,Â n_{0}Â = 1

f(n) = O (g(n)) = O (n^{2})Â for c = 4, n_{0}Â = 4

and so on.

**Example: **Find upper bound of running time of a cubic function f(n) = 2n^{3 }+ 4n + 5.

To find upper bound of f(n), we have to find c and n_{0} such that 0 â‰¤ f(n) â‰¤ c Ã— g(n) for all n â‰¥ n_{0}

0 â‰¤ f(n) â‰¤ c.g(n)

0 â‰¤ 2n^{3} + 4n + 5 â‰¤ c **Ã—** g(n)

0 â‰¤ 2n^{3 }+ 4n + 5 â‰¤ 2n^{3}+ 4n^{3} + 5n^{3}, for all n Â³ 1

0 â‰¤ 2n^{3 }+ 4n + 5 â‰¤ 11n^{2}

So, c = 11, g(n) = n^{3} and n_{0} = 1

Tabular approach

0 â‰¤ 2n^{3} + 4n + 5 â‰¤ c **Ã— **g(n)

0 â‰¤ 2n^{3 }+ 4n + 5 â‰¤ 3n^{3}

Now, manually find out the proper n_{0}, such that f(n) â‰¤ c **Ã— **g(n)

n | f(n) = 2n^{3} + 4n + 5 | c.g(n) = 3n^{3} |

1 | 11 | 3 |

2 | 29 | 24 |

3 | 71 | 81 |

4 | 149 | 192 |

From Table, for n â‰¥ 3, f(n) â‰¤ c **Ã— **g(n) holds true. So, c = 3, g(n) = n^{3} and n_{0} = 3. There can be such multiple pair of (c, n_{0})

f(n) = O(g(n)) = O(n^{3}) for c = 11, n_{0} = 1

f(n) = O(g(n)) = O(n^{3}) for c =3, n_{0} = 3 and so on.

## Lower Bound

Lower bound of any function is defined as follow:

Let f(n) and g(n) are two nonnegative functions indicating the running time of two algorithms. We say the function g(n) is lower bound of function f(n) if there exist some positive constants c and n

_{0}such that 0 ï‚£â‰¤ c.g(n) â‰¤ f(n) for all n â‰¥ n_{0}. It is denoted as f(n) = Î© (g(n)).

### Examples on Lower Bound Asymptotic Notation

**Example: **Find lower bound of running time of constant function f(n) = 23.

To find lower bound of f(n), we have to find c and n_{0} such that { 0 â‰¤ c **Ã— **g(n) â‰¤ f(n) for all n â‰¥ n_{0 }}

0 â‰¤ c **Ã—** g(n) â‰¤ f(n)

0 â‰¤ c **Ã—** g(n) â‰¤ 23

0 â‰¤ 23.1 â‰¤ 23 â†’ true

0 â‰¤ 12.1 â‰¤ 23 â†’ true

0 â‰¤ 5.1 â‰¤ 23 â†’ true

Above all three inequalities are true and there exists such infinite inequalities

So c = 23, c = 12, c = 5 and g(n) = 1. Any value of c which is less than or equals to 23, satisfies the above inequality, so all such value of c are possible. Function f(n) is constant, so it does not depend on problem size n. Hence n_{0} = 1

f(n) = Î© (g(n)) = Î© (1) for c = 23, n_{0} = 1

f(n) = Î© (g(n)) = Î© (1) for c = 12, n_{0} = 1 and so on.

**Example: ** Find lower bound of running time of a linear function f(n) = 6n + 3.

To find lower bound of f(n), we have to find c and n_{0} such that 0 â‰¤ c.g(n) â‰¤ f(n) for all n â‰¥ n_{0}

0 â‰¤ c **Ã— **g(n) â‰¤ f(n)

0 â‰¤ c **Ã—** g(n) â‰¤ 6n + 3

0 â‰¤ 6n â‰¤ 6n + 3 â†’ true, for all n â‰¥ n_{0}

0 â‰¤ 5n â‰¤ 6n + 3 â†’ true, for all n â‰¥ n_{0}

Above both inequalities are true and there exists such infinite inequalities. So,

f(n) = Î© (g(n)) = Î© (n) for c = 6, n_{0} = 1

f(n) = Î© (g(n)) = Î© (n) for c = 5, n_{0} = 1

and so on.

**Example:** Find lower bound of running time of quadratic function f(n) = 3n^{2} + 2n + 4.

To find lower bound of f(n), we have to find c and n_{0} such that 0 â‰¤ c.g(n) â‰¤ f(n) for all n Â³ n_{0}

0 â‰¤ c **Ã— **g(n) â‰¤ f(n)

0 â‰¤ c **Ã— **g(n) â‰¤ 3n^{2} + 2n + 4

0 â‰¤ 3n^{2} â‰¤ 3n^{2}Â + 2n + 4, â†’ true, for all n â‰¥ 1

0 â‰¤ n^{2} â‰¤ 3n^{2}Â + 2n + 4,Â Â â†’ true, for all n â‰¥ 1

Above both inequalities are true and there exists such infinite inequalities.

So, f(n) = Î© (g(n)) = Î© (n^{2}) for c = 3, n_{0} = 1

f(n) = Î© (g(n)) = Î© (n^{2}) for c = 1, n_{0} = 1

and so on.

**Example:** Find lower bound of running time of quadratic function f(n) = 2n^{3} + 4n + 5.

To find lower bound of f(n), we have to find c and n_{0} such that 0 â‰¤ c.g(n) â‰¤ f(n) for all n â‰¥ n_{0}

0 â‰¤ c **Ã— **g (n) â‰¤ f(n)

0 â‰¤ c **Ã— **g (n) â‰¤ 2n^{3 }+ 4n + 5

0 â‰¤ 2n^{3 }â‰¤ 2n^{3 }+ 4n + 5 â†’ true, for all n â‰¥ 1

0 â‰¤ n^{3}Â â‰¤ 2n^{3 }+ 4n + 5 â†’ true, for all n â‰¥ 1

Above both inequalities are true and there exists such infinite inequalities.

So, f(n) = Î© (g(n)) = Î© (n^{3}) for c = 2, n_{0} = 1

f(n) = Î© (g(n)) = Î© (n^{3}) for c = 1, n_{0} = 1

and so on.

## Tight Bound

Tight bound of any function is defined as follow:

Let f(n) and g(n) are two nonnegative functions indicating running time of two algorithms. We say the function g(n) is tight bound of function f(n) if there exist some positive constants c

_{1}, c_{2,}and n_{0}such that 0 â‰¤ c_{1}Ã—g(n) â‰¤ f(n) â‰¤ c_{2}Ã—g(n) for all n â‰¥ n_{0}. It is denoted as f(n) = Î˜ (g(n)).

### Examples on Tight Bound Asymptotic Notation:

**Example:** Find tight bound of running time of constant function f(n) = 23.

To find tight bound of f(n), we have to find c_{1}, c_{2} and n_{0} such that, 0 â‰¤ c_{1}Ã— g(n) â‰¤ f(n) â‰¤ c_{2}** Ã—** g(n) for all n â‰¥ n_{0}

0 â‰¤ c_{1}**Ã—** g(n) â‰¤ 23 â‰¤ c_{2 }**Ã— **g(n)

0 â‰¤ 22 **Ã—**1 â‰¤ 23 â‰¤ 24 **Ã— **1, â†’ true for all n â‰¥ 1

0 â‰¤ 10 **Ã—**1 â‰¤ 23 â‰¤ 50 **Ã—** 1, â†’ true for all n â‰¥ 1

Above both inequalities are true and there exists such infinite inequalities.

So, (c_{1}, c_{2}) = (22, 24) and g(n) = 1, for all n â‰¥ 1

(c_{1}, c_{2}) = (10, 50) and g(n) = 1, for all n â‰¥ 1

f(n) = Î˜ (g (n)) = Î˜ (1) for c_{1} = 22, c_{2} = 24, n_{0} = 1

f(n) = Î˜ (g (n)) = Î˜ (1) for c_{1} = 10, c_{2} = 50, n_{0} = 1

and so on.

**Example:** Find tight bound of running time of a linear function f(n) = 6n + 3.

To find tight bound of f(n), we have to find c_{1}, c_{2} and n_{0} such that, 0 â‰¤ c_{1}**Ã—** g(n) â‰¤ f(n) â‰¤ c_{2} **Ã—** g(n) for all n â‰¥ n_{0}

0 â‰¤ c_{1}**Ã—** g(n) â‰¤ 6n + 3 â‰¤ c_{2 }**Ã—**** **g(n)

0 â‰¤ 5n â‰¤ 6n + 3 â‰¤ 9n, for all n â‰¥ 1

Above inequality is true and there exists such infinite inequalities.

So, f(n) = Î˜(g(n)) = Î˜(n) for c_{1} = 5, c_{2} = 9, n_{0} = 1

**Example:** Find tight bound of running time of quadratic function f(n) = 3n^{2} + 2n + 4.

To find tight bound of f(n), we have to find c_{1}, c_{2} and n_{0} such that, 0 â‰¤ c_{1 }**Ã—** g(n) â‰¤ f(n) â‰¤ c_{2}** Ã—** g(n) for all n â‰¥ n_{0}

0 â‰¤ c_{1 }**Ã—** g(n) â‰¤ 3n^{2 }+ 2n + 4 â‰¤ c_{2 }**Ã—** g(n)

0 â‰¤ 3n^{2} â‰¤ 3n^{2} + 2n + 4 â‰¤ 9n^{2}, for all n â‰¥ 1

Above inequality is true and there exists such infinite inequalities. So,

f(n) = Î˜(g(n)) = Î˜(n^{2}) for c_{1} = 3, c_{2} = 9, n_{0} = 1

**Example:** Find tight bound of running time of a cubic function f(n) = 2n^{3} + 4n + 5.

To find tight bound of f(n), we have to find c_{1}, c_{2} and n_{0} such that, 0 â‰¤ c_{1 }**Ã—** g(n) â‰¤ f(n) â‰¤ c_{2 }**Ã—** g(n) for all n â‰¥ n_{0}

0 â‰¤ c_{1 }**Ã—** g(n) â‰¤ 2n^{3 }+ 4n + 5 â‰¤ c_{2 }**Ã—** g(n)

0 â‰¤ 2n^{3 }â‰¤ 2n^{3 }+ 4n + 5 â‰¤ 11n^{3}, for all n â‰¥ 1

Above inequality is true and there exists such infinite inequalities. So,

f(n) = Î˜(g(n)) = Î˜(n^{3}) for c_{1} = 2, c_{2} = 11, n_{0} = 1

## General Problems

**Example: **Show that : (i) 3n + 2 = Î˜(n) (ii) 6*2^{n} + n^{2} = Î˜(2^{n})

(i) 3n + 2 = Î˜(n)

To prove above statement, we have to find c_{1}, c_{2} and n_{0} such that, 0 â‰¤ c_{1}**Ã—** g(n) â‰¤ f(n) â‰¤ c_{2} g(n) for all n â‰¥ n_{0}

0 â‰¤ c_{1}**Ã—** g(n) â‰¤ 3n + 2 â‰¤ c_{2 }**Ã—**** **g(n)

0 â‰¤ 2n â‰¤ 3n + 2 â‰¤ 5n, for all n â‰¥ 1

So, f(n) = Î˜(g(n)) = Î˜(n) for c_{1} = 2, c_{2} = 5 n_{0} = 1

(ii) 6*2^{n} + n^{2} = Î˜(2^{n})

To prove above statement, we have to find c_{1}, c_{2} and n_{0} such that, 0 â‰¤ c_{1}**Ã—** g(n) â‰¤ f(n) â‰¤ c_{2} g(n) for all n â‰¥ n_{0}

0 â‰¤ c_{1}**Ã—** g(n) â‰¤ 6*2^{n} + n^{2} â‰¤ c_{2 }**Ã—** g(n)

0 â‰¤ 6.2^{n} â‰¤ 6*2^{n} + n^{2} â‰¤ 7*2^{n}, for all n â‰¥ 1

So, f(n) = Î˜(g(n)) = Î˜(2^{n}) for c_{1} = 6, c_{2} = 7 n_{0} = 1

**Example: **Let f(n) and g(n) be asymptotically positive functions. Prove or disprove following. f(n) + g(n) = q(min(f(n), g(n))).

Function f(n) and g(n) are non-negative functions such that there exist f(n) â‰¥ 0 and g(n) â‰¥ 0, for all n â‰¥ n_{0}.

For all such n â‰¥ n_{0}, f(n) + g(n) â‰¥ f(n) â‰¥ 0

Similarly, f(n) + g(n) â‰¥ g(n) â‰¥ 0

Adding both inequalities, f(n) + g(n) â‰¥ min(f(n), g(n))

â‡’ min(f(n), g(n)) â‰¤ c.( f(n) + g(n)) for all n â‰¥ n_{0} with c = 1.

From the definition of big oh, min(f(n), g(n)) = O(f(n) + g(n)).

However converse is not true. Let us take f(n) = n and g(n) = n^{2}. i.e. min(f(n), g(n)) = n. It is easy to show that for any n_{0}, c there is always exist n such that n < c(n + n^{2}). So it is proved that min(f(n), g(n)) = Î©(f(n) + g(n)) is false.

Hence, the given statement is false.

**Example: **Prove that (n + a)^{b} = Î˜( n^{b }), b > 0

To prove that said statement, we show find positive constants c_{1}, c_{2} and n_{0} such that 0 â‰¤ c_{1}n^{b} â‰¤ (n + a)^{b} â‰¤ c_{2}n^{b}, for all n â‰¥ n_{0}.

Here, a is constant, so for sufficient large value of n, n â‰¥ |a|, so

n + a â‰¤ n + | a |

This also implies, n + a â‰¤ n + |a| â‰¤ n + n

For further large value of n, n â‰¥ 2|a|, so |a| â‰¤ (n/2)

n + a â‰¥ n – |a| â‰¥ (n/2)

When n â‰¥ 2|a|, we have

0 = (1/2)n â‰¤ n + a â‰¤ 2n

Given that, b is positive constant, so raising the above equation to the power b does not change the relation,

0 = (n/2)^{b}Â â‰¤ (n + a)^{b}Â â‰¤ (2n)^{b}

0 = (1/2)^{b} (n)^{b } â‰¤ (n + a)^{b } â‰¤ (2)^{b }(n)^{b}

So the constants c_{1} = (1/2), c_{2} = 2 and n_{0} = 2|a| proves the given statement

**Example:** Is 2^{n+1} = ÎŸ(2^{n}) ? Explain.

To prove the given statement, we must find constants c and n_{0} such that 0 â‰¤ 2^{n+1} â‰¤ c.2^{n} for all n â‰¥ n_{0}.

2^{n+1} = 2 * 2^{n} for all n. We can satisfy the given statement with c = 2 and n_{0} = 1.

**Example:** Find big theta and big omega notation of f(n) = 14 * 7 + 83

**1. Big omega notation :**

We have to find c and n_{0} such that 0 â‰¤ c **Ã—** g(n) â‰¤ f(n) for all n â‰¥ n_{0}

0 â‰¤ c **Ã—** g(n) â‰¤ f(n)

0 â‰¤ c **Ã—** g(n) â‰¤ 14 * 7 + 23

0 â‰¤ c **Ã—** g(n) â‰¤ 181 for all n Â³ 1

0 â‰¤ 181.1 â‰¤ 181

For c = 181, g(n) = 1 and n_{0} = 1

f(n) = Î©(g(n)) = Î©(1) for c = 181, n_{0} = 1

**2. Big theta notation:**

We have to find such c_{1}, c_{2} and n_{0} such that,

0 â‰¤ c_{1} **Ã—** g(n) â‰¤ f(n) â‰¤ c_{2} **Ã—** g(n) for all n â‰¥ n_{0}

0 â‰¤ c_{1} .g(n) â‰¤ f(n) â‰¤ c_{2} **Ã— **g(n)

0 â‰¤ c_{1 }**Ã— **g(n) â‰¤ 181 â‰¤ c_{2} **Ã— **g(n)

0 â‰¤ 180.1 â‰¤ 181 â‰¤ 182.1, for all n Â³ 1

f(n) = Î˜(g(n)) = Î˜(1), for c_{1}Â = 180, c_{2}Â = 182, n_{0}Â = 1

**Additional Reading**: More Examples