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

Assignment 1

This document contains 4 questions related to analyzing the time complexity of algorithms using Big-O notation: 1. A sorting algorithm with time complexity O(n log n) takes 1 ms to sort 1000 items. The question asks to derive a formula for the time T(n) to sort n items and estimate the time to sort 1,000,000 items. 2. A quadratic algorithm with time complexity T(n) = cn^2 takes T(N) seconds to process N items. The question asks how long it will take to process 5000 items if N = 100 and T(N) = 1 ms. 3. Several expressions are given for the processing time T(n) of algorithms

Uploaded by

NoXiouSGT Gaming
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)
243 views2 pages

Assignment 1

This document contains 4 questions related to analyzing the time complexity of algorithms using Big-O notation: 1. A sorting algorithm with time complexity O(n log n) takes 1 ms to sort 1000 items. The question asks to derive a formula for the time T(n) to sort n items and estimate the time to sort 1,000,000 items. 2. A quadratic algorithm with time complexity T(n) = cn^2 takes T(N) seconds to process N items. The question asks how long it will take to process 5000 items if N = 100 and T(N) = 1 ms. 3. Several expressions are given for the processing time T(n) of algorithms

Uploaded by

NoXiouSGT Gaming
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

Assignment 1

Que 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, that is,
T(n) = cn 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.

Que 2 A quadratic algorithm with processing time T(n) = cn2 spends T(N) seconds for processing N data
items. How much time will be spent for processing n = 5000 data items, assuming that N = 100
and T(N) = 1ms?

Que 3 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(. . .)


3
5 + 0.001n + 0.025n
500n + 100n 1.5 + 50n log10 n
0.3n + 5n 1.5 + 2.5 * n 1.75
n 2 log2 n + n(log2 n) 2
n log3 n + n log2 n
3 log8 n + log2 log2 log2 n
100n + 0.01n 2
0.01n + 100n 2
2n + n 0.5 + 0.5n 1.25
0.01n log2 n + n(log2 n) 2
100n log3 n + n 3 + 100n
0.003 log4 n + log2 log2 n
Que 4 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 or If it is FALSE then write the


Statement
FALSE ? 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 + 8n 2 + 100n 3 = O(n 4 )
5n + 8n 2 + 100n 3 = O(n 2 log n)

You might also like