0% found this document useful (0 votes)
116 views1 page

Tutorial 2

This document contains 5 questions related to analyzing algorithms using Big-O notation. The questions cover topics like deriving time complexity formulas based on sample data, determining true/false statements about Big-O notation rules, comparing two algorithms based on their time complexities, and determining asymptotic bounds.

Uploaded by

LeongFon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views1 page

Tutorial 2

This document contains 5 questions related to analyzing algorithms using Big-O notation. The questions cover topics like deriving time complexity formulas based on sample data, determining true/false statements about Big-O notation rules, comparing two algorithms based on their time complexities, and determining asymptotic bounds.

Uploaded by

LeongFon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

QUESTION 1

A sorting method with “Big-Oh” complexity O(n log n) spends exactly 1 millisecond to sort
1,000 data items. Assuming that time T(n) of sorting n items is directly proportional to (n log n),
derive a formula for T(n), given the time T(N) for sorting N items, and estimate how long this
method will sort 1,000,000 items.

QUESTION 3

Algorithms A and B spend exactly TA(n) = c1n log2 n and TB(n) = c2n2 microseconds,
respectively, for a problem of size n. Find the best algorithm for processing n = 220 data items if
the algorithm A spends 10 microseconds to process 1024 items and the algorithm B spends only
1 microsecond to process 1024 items.

QUESTION 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.

TRUE OR FALSE CORRECT FORM


O(f + g) = O(f) + O(g)
O(f · g) = O(f) · O(g)
if g = O(f) and h = O(f)
then g = O(h)
5n + 8n2 + 100n3 = O(n4)
5n+8n2+100n3 = O(n2 log n)

QUESTION 4

Algorithms A and B spend exactly TA(n) = 0.1n2 log10 n and TB(n) = 2.5n2 microseconds,
respectively, for a problem of size n. Choose the algorithm, (which is better in the Big-Oh sense),
and find out a problem size n0 such that for any larger size n > n0 the chosen algorithm
outperforms the other. If your problems are of the size n ≤ 109, which algorithm will you
recommend to use?

QUESTION 5

Is 2n+1 = O(2n)? Is 22n = O(2n)?

You might also like