CSE222 Homework 1 Solved

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

 

  1. Given any two functions f(n) and g(n), show that f(n) + g(n) = Θ(max{f(n),g(n)}))

(10P).P).).

  1. Show that f(n) =n2+ 2n+ 1 is Θ(n2) using induction. ( If you use l’Hopital, you will lose points.)(5P).).
  2. P).rove the functions below (40P).P).).
  3. a) If f(n) = 10P). log(n) + 5 (log(n))3 + 7n + 3n2 + 6n3, then f(n) = O(n3) (5P).) b) 1 = O(n) (5P).)
    1. n = O(n2) (5P).)
    2. log(n) = O(n), 2 n + 1 = O(n) (5P).)
    3. n = Ω(1) (5P).)
    4. n2 = Ω(n) (5P).)
    5. n2 = Ω(n log(n)) (5P).)
    6. 2 n + 1 = Θ(n) (5P).)
  4. Sort the following functions from fastest to slowest with respect to their growth rate. Do not use l’Hopital! P).rove all of them using induction (20P).P).).

n!,  nk+n , n,  logn,  n(logn),  e7,  20P).19,  -7n+m,  n4,  10P).0P).*n

*k and m are constants.

  1. Explain the time complexity of the code snippets below (10P).P).).

a-)System.out.println = SOP void method4(int [] arr) { for(int i = 0; i < arr.length; i++) { for(int k = arr.length – 1; k > 0; k = k / 3 ) { SOP(arr[i]);

}

} }

b-)

void method3(int [] arr)

{ for(int i = 0; i < arr.length; i++)

{ method1(arr);

method2(arr);

}

}

void method1(int [] arr)

{ int n = arr.length;

for(int i = n – 1 ; i >= 0; i = i – 3)

{

SOP (arr[i]);

}

}

  1. Calculate the time complexity of the following recurrence functions (Use the master theorem)
    • T(n) = T(n/7) + n4
    • T(n) = T(n/99) + n75
    • T(n) = 23T(n/12) + 6
  2. Write mergesort with pseudo-code and analyze the algorithm’s worst case, best case and average case using asymptotic notations
  • HW1-v14qu1.zip