Homework 1 Solution

$30.00 $24.00

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…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)
  1. Use the formal definitions of asymptotic notations to determine whether the following statements are true or not. (Answers without explanation will not be accepted.)

    1. (2n + n3) O(4n)

    1. 10n2 + 7n + 3 Ω(n)

    2. n2 + n o(n2)

    1. 3 log22 n θ(log2 n2)

    1. (n3 + 1)6 O(n3)

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

    1. 2n log (n + 2)2 + (n + 2)2 log n2

    2. 0.001n4 + 3n3 + 1

  1. Compare and sort the following functions in terms of their orders of growth by using limit approach.

    1. log n, nlog n, n1.5

    2. n!, 2n, n2 (Use Stirling’s formula for n!)

(c) n log n, n

    1. n2n, 3n

    1. n + 10, n3

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

    1. What is its basic operation?

    1. How many times is the basic operation executed? (Set up a sum expressing the number of times the algorithm’s basic operation is executed.)

    1. What is the time complexity of the algorithm? (Derive from the sum expression obtained from question (b))

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

    1. What is its basic operation?

    1. How many times is the basic operation executed? (Set up a sum expressing the number of times the algorithm’s basic operation is executed.)

    1. What is the time complexity of the algorithm? (Derive from the sum expression obtained from question (b))

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

Homework 1 Solution
$30.00 $24.00