Description
-
Use the formal definitions of asymptotic notations to determine whether the following statements are true or not. (Answers without explanation will not be accepted.)
-
-
(2n + n3) ∈ O(4n)
-
√
-
-
10n2 + 7n + 3 ∈ Ω(n)
-
n2 + n ∈ o(n2)
-
-
-
3 log22 n ∈ θ(log2 n2)
-
-
-
(n3 + 1)6 ∈ O(n3)
-
-
Use the formal definition of θ notation to find θ(g(n)) class the following functions belong to. Give the simplest g(n) possible in your answers.
-
-
2n log (n + 2)2 + (n + 2)2 log n2
-
0.001n4 + 3n3 + 1
-
-
Compare and sort the following functions in terms of their orders of growth by using limit approach.
-
-
log n, nlog n, n1.5
-
n!, 2n, n2 (Use Stirling’s formula for n!)
-
√
(c) n log n, n
-
-
n2n, 3n
-
√
-
-
n + 10, n3
-
-
Consider the worst case of the following algorithm.
algorithm1(B[0..n-1,0..n-1])
for i=0 to n-2 do
for j=i+1 to n-1 do
if B[i,j]!=B[j,i]
return false
return true
1
-
-
What is its basic operation?
-
-
-
How many times is the basic operation executed? (Set up a sum expressing the number of times the algorithm’s basic operation is executed.)
-
-
-
What is the time complexity of the algorithm? (Derive from the sum expression obtained from question (b))
-
-
Consider the following algorithm.
algorithm2(A[0..n-1, 0..n-1], B[0..n-1, 0..n-1])
for i=0 to n-1 do
for j=0 to n-1 do
C[i,j]=0.0
for k=0 to n-1 do
C[i,j]=C[i,j]+A[i,k]*B[k,j]
return C
-
-
What is its basic operation?
-
-
-
How many times is the basic operation executed? (Set up a sum expressing the number of times the algorithm’s basic operation is executed.)
-
-
-
What is the time complexity of the algorithm? (Derive from the sum expression obtained from question (b))
-
-
Design an algorithm that finds and prints all pairs whose multiplication yields the desired number in an unordered array. For example, let the array be {1,2,3,6,5,4} and let the desired number be 6. Then, our pairs will be (1,6) and (2,3). Write your algorithm as pseudo-code, and find the time complexity of the algorithm.
Notes:
-
Submissions must be handwritten and readable.
-
The homework must be done individually. No collaboration is allowed.
2