BEC20602 TEST 1 Excersice
1. Assume that each of the expressions below gives the processing time T (n)
spent by an algorithm for solving a problem of size n. Select the dominant
term(s) having the steepest increase in n and specify the lowest Big-Oh
complexity of each algorithm.
Expression Dominant term(s) O(. . .)
5 + 0.001n3 + 0.025n
500n + 100n1.5 + 50n log10 n
0.3n + 5n1.5 + 2.5 · n1.75
n2 log2 n + n(log2 n)2
n log3 n + n log2 n
3 log8 n + log2 log2 log2 n
100n + 0.01n2
0.01n + 100n2
2n + n0.5 + 0.5n1.25
0.01n log2 n + n(log2 n)2
100n log3 n + n3 + 100n
0.003 log4 n + log2 log2 n
2. The statements below show some features of “Big-Oh” notation for the
functions f ≡ f (n) and g ≡ g(n). Determine whether each statement is
TRUE or FALSE and correct the formula in the latter case.
Is it TRUE If it is FALSE then write
Statement or FALSE? the correct formula
Rule of sums:
O(f + g) = O(f ) + O(g)
Rule of products:
O(f · g) = O(f ) · O(g)
Transitivity:
if g = O(f ) and h = O(f )
then g = O(h)
5n + 8n2 + 100n3 = O(n4 )
5n+8n2 +100n3 = O(n2 log n)
solutions
Expression Dominant term(s) O(. . .)
5 + 0.001n3 + 0.025n 0.001n3 O(n3 )
500n + 100n1.5 + 50n log10 n 100n1.5 O(n1.5 )
0.3n + 5n1.5 + 2.5 · n1.75 2.5n1.75 O(n1.75 )
n2 log2 n + n(log2 n)2 n2 log2 n O(n2 log n)
n log3 n + n log2 n n log3 n, n log2 n O(n log n)
3 log8 n + log2 log2 log2 n 3 log8 n O(log n)
1. 100n + 0.01n2 0.01n2 O(n2 )
0.01n + 100n2 100n2 O(n2 )
2n + n0.5 + 0.5n1.25 0.5n1.25 O(n1.25 )
0.01n log2 n + n(log2 n)2 n(log2 n)2 O(n(log n)2 )
100n log3 n + n3 + 100n n3 O(n3 )
0.003 log4 n + log2 log2 n 0.003 log4 n O(log n)
If it is FALSE then
Is it TRUE
Statement write
or FALSE?
the correct formula
Rule of sums: O(f + g) =
O(f + g) = O(f ) + O(g) FALSE max {O(f ), O(g)}
Rule of products:
O(f · g) = O(f ) · O(g) TRUE
2. Transitivity: if g = O(f ) and
if g = O(f ) and h = O(f ) FALSE f = O(h) then
then g = O(h) g = O(h)
5n + 8n2 + 100n3 = O(n4 )
TRUE
5n + 8n2 + 100n3 =
5n + 8n2 + 100n3 = O(n3 )
O(n2 log n) FALSE