
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

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 n ≥ n 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 n ≥ n 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 n ≥ n 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 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 ≥ 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 n ≥ n 0. Let us check this condition: if n^3 + 20 n ≥ c · 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 n ≥ n 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.