CS 2605 Homework 6 - Complexity Analysis and Function Classification - Prof. William D. Mc, Assignments of Data Structures and Algorithms

Cs 2605 homework 6 from summer i 2007. The assignment includes tasks on complexity analysis of a function, finding the smallest value of n for given inequalities, function classification, and deciding the order of certain statements. Students are required to submit their solutions as plain text files or ms word documents.

Typology: Assignments

Pre 2010

Uploaded on 02/13/2009

koofers-user-f6h
koofers-user-f6h 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 2605 Homework 6 Summer I 2007
Last modified: 6/22/2007 11:06:52 AM 1
You will submit your solution to this assignment to the Curator System (as HW6). Your solution must be either a plain text file
or a MS Word document.
1. [20 points] Using the rules given in the course notes, perform an exact count complexity analysis of the body of the
following function. (Your answer should be a function of the parameter N.)
void Mystery(int M[N][N], const int N) {
for (int R = 0; R < N; R++) {
for (int C = 1; C < N; C++) {
if (M[R][C-1] < M[R][C])
M[R][C-1] = M[R][C];
else {
M[R][C] = M[R][C-1];
M[R][C-1] = 0;
}
}
}
}
Note: array index operations count 1 time unit each.
2. [10 points] For each of the following inequalities, what is the smallest value of N such that the inequality holds for all n
>= N?
(a) nn log101.0
(b) nnnn log20
2
12
3. [25 points] Divide the following functions into non-overlapping categories (Θ equivalence classes), so that two
functions, say f(n) and g(n), are in the same category if and only if f(n) is Θ(g(n)). Arrange the categories from the
lowest order of magnitude to the highest. A function may be in a category by itself, or there may be several functions in
the same category.
5000 (log n)5 3
n
log n n + log n n3
n2 log n n2 – 100n 4n + n1/2
log log n2 n0.3 n
2
log n2 (n2 + 4)1/2 2
n
4. [10 points] Using any theorems from the course notes, give a formal proof that:
()
(
)
)( is log5 2
nnnnn Θ++
pf2

Partial preview of the text

Download CS 2605 Homework 6 - Complexity Analysis and Function Classification - Prof. William D. Mc and more Assignments Data Structures and Algorithms in PDF only on Docsity!

CS 2605 Homework 6 Summer I 2007

Last modified: 6/22/2007 11:06:52 AM 1

You will submit your solution to this assignment to the Curator System (as HW6). Your solution must be either a plain text file

or a MS Word document.

  1. [20 points] Using the rules given in the course notes, perform an exact count complexity analysis of the body of the

following function. (Your answer should be a function of the parameter N.)

void Mystery(int M[N][N], const int N) {

for (int R = 0; R < N; R++) { for (int C = 1; C < N; C++) { if (M[R][C-1] < M[R][C]) M[R][C-1] = M[R][C]; else { M[R][C] = M[R][C-1]; M[R][C-1] = 0; } } } }

Note: array index operations count 1 time unit each.

  1. [10 points] For each of the following inequalities, what is the smallest value of N such that the inequality holds for all n

= N?

(a) 0. 1 n ≥ 10 log n

(b) n n 20 n log n 2

  1. [25 points] Divide the following functions into non-overlapping categories (Θ equivalence classes), so that two

functions, say f(n) and g(n), are in the same category if and only if f(n) is Θ(g(n)). Arrange the categories from the lowest order of magnitude to the highest. A function may be in a category by itself, or there may be several functions in the same category.

5000 (log n)

5 3

n

log n n + log n n

3

n

2 log n n

2

  • 100n 4n + n

1/

log log n

2 n

n

2

log n

2 (n

2

1/ 2

n

  1. [10 points] Using any theorems from the course notes, give a formal proof that:

( 5 )( log ) is ( )

2 nn + n + n Θ n

CS 2605 Homework 6 Summer I 2007

Last modified: 6/22/2007 11:06:52 AM 2

  1. [15 points] Decide if each of the following statements is true or false — no justification is necessary.

(a) ( 3 log ) 10 2 is ( )

3 nn + n Θ n

(b) 10 100 is ( )

2 nn + Ω n

(c) 2 is ( )

3 4 n n

n − Ω

  1. [20 points] Suppose that executing an algorithm on input of size N requires executing T(N) = N log N + 8N instructions.

How long would it take to execute this algorithm on hardware capable of carrying out 2^23 instructions per second if N = 230? (Give your answer in hours, minutes and seconds, to the nearest second.)