Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Big omega notation example, Exercises of Algorithms and Programming

contains information and examples of Big omega notation

Typology: Exercises

2018/2019

Uploaded on 09/01/2019

radhashaym66789
radhashaym66789 🇮🇳

1 document

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Big-Oh notation: few examples
Example 1: Prove that running time T(n) = n3 + 20n + 1 is O(n3)
Proof: by the Big-Oh definition, T(n) is O(n3) if T(n) c·n3 for some n n0 . Let
us check this condition: if n3 + 20n + 1 c·n3 then c
nn
++ 32
120
1. Therefore,
the Big-Oh condition holds for n n0 = 1 and c 22 (= 1 + 20 + 1). Larger
values of n0 result in smaller factors c (e.g., for n0 = 10 c 1.201 and so on) but in
any case the above statement is valid.
Example 2: Prove that running time T(n) = n3 + 20n + 1 is not O(n2)
Proof: by the Big-Oh definition, T(n) is O(n2) if T(n) c·n2 for some n n0 . Let
us check this condition: if n3 + 20n + 1 c·n2 then c
n
n
n++ 2
120 . Therefore,
the Big-Oh condition cannot hold (the left side of the latter inequality is growing
infinitely, so that there is no such constant factor c).
Example 3: Prove that running time T(n) = n3 + 20n + 1 is O(n4)
Proof: by the Big-Oh definition, T(n) is O(n4) if T(n) c·n4 for some n n0 . Let
us check this condition: if n3 + 20n + 1 c·n4 then c
nn
n
++ 43
1201 . Therefore,
the Big-Oh condition holds for n n0 = 1 and c 22 (= 1 + 20 + 1). Larger values
of n0 result in smaller factors c (e.g., for n0 = 10 c 0.10201 and so on) but in any
case the above statement is valid.
Example 4: Prove that running time T(n) = n3 + 20n is (n2)
Proof: by the Big-Omega definition, T(n) is (n2) if T(n) c·n2 for some n n0 .
Let us check this condition: if n3 + 20n c·n2 then c
n
n+ 20 . The left side of
this inequality has the minimum value of 8.94 for 47.420 =n Therefore, the
Big-Omega condition holds for n n0 = 5 and c 9. Larger values of n0 result in
larger factors c (e.g., for n0 = 10 c 12.01) but in any case the above statement is
valid.

Partial preview of the text

Download Big omega notation example and more Exercises Algorithms and Programming in PDF only on Docsity!

Big-Oh notation: few examples

Example 1: Prove that running time T( n ) = n^3 + 20 n + 1 is O( n^3 ) Proof: by the Big-Oh definition, T( n ) is O( n^3 ) if T( n ) ≤ c · n^3 for some nn 0. Let us check this condition: if n^3 + 20 n + 1 ≤ c · n^3 then 1 + (^) n^20 2 + n^13 ≤ c. Therefore, the Big-Oh condition holds for n ≥ n 0 = 1 and c ≥ 22 (= 1 + 20 + 1). Larger values of n 0 result in smaller factors c (e.g., for n 0 = 10 c ≥ 1.201 and so on) but in any case the above statement is valid.

Example 2: Prove that running time T( n ) = n^3 + 20 n + 1 is not O( n^2 ) Proof: by the Big-Oh definition, T( n ) is O( n^2 ) if T( n ) ≤ c · n^2 for some nn 0. Let us check this condition: if n^3 + 20 n + 1 ≤ c · n^2 then n + (^20) n^ + n^12 ≤ c. Therefore, the Big-Oh condition cannot hold (the left side of the latter inequality is growing infinitely, so that there is no such constant factor c ).

Example 3: Prove that running time T( n ) = n^3 + 20 n + 1 is O( n^4 ) Proof: by the Big-Oh definition, T( n ) is O( n^4 ) if T( n ) ≤ c · n^4 for some nn 0. Let us check this condition: if n^3 + 20 n + 1 ≤ c · n^4 then (^) n^1^ + (^) n^203 + n^14 ≤ c. Therefore, the Big-Oh condition holds for nn 0 = 1 and c ≥ 22 (= 1 + 20 + 1). Larger values of n 0 result in smaller factors c (e.g., for n 0 = 10 c ≥ 0.10201 and so on) but in any case the above statement is valid.

Example 4: Prove that running time T( n ) = n^3 + 20 n is Ω( n^2 ) Proof: by the Big-Omega definition, T( n ) is Ω( n^2 ) if T( n ) ≥ c · n^2 for some nn 0. Let us check this condition: if n^3 + 20 nc · n^2 then n + (^20) n^ ≥ c. The left side of this inequality has the minimum value of 8.94 for n = 20 ≅ 4. 47 Therefore, the Big-Omega condition holds for nn 0 = 5 and c ≤ 9. Larger values of n 0 result in larger factors c (e.g., for n 0 = 10 c ≤ 12.01) but in any case the above statement is valid.