Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
729 views2 pages

Big O

This document contains two exercises on analyzing algorithm complexity using Big-O notation: 1. The first exercise identifies the dominant terms and determines the Big-O complexity for several algorithms expressed as functions of input size n. The dominant terms and complexities identified are: O(n3), O(n1.5), O(n1.75), O(n2 log n), O(n log n), O(log n), O(n2), etc. 2. The second exercise determines whether statements about properties of Big-O notation are true or false. It finds that the rule of sums and the statement about 5n + 8n2 + 100n3 being O(n4)

Uploaded by

sufikasih
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)
729 views2 pages

Big O

This document contains two exercises on analyzing algorithm complexity using Big-O notation: 1. The first exercise identifies the dominant terms and determines the Big-O complexity for several algorithms expressed as functions of input size n. The dominant terms and complexities identified are: O(n3), O(n1.5), O(n1.75), O(n2 log n), O(n log n), O(log n), O(n2), etc. 2. The second exercise determines whether statements about properties of Big-O notation are true or false. It finds that the rule of sums and the statement about 5n + 8n2 + 100n3 being O(n4)

Uploaded by

sufikasih
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
You are on page 1/ 2

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

You might also like