Docsity

Algorithm Analysis and Design Homework Set 2 for CPSC 5115 - Prof. Edward Bosworth, Assignments of Computer Architecture and Organization

Toggle sidebar
bg1
CPSC 5115 Algorithm Analysis and Design
Homework Set 2 Due Thursday, September 13, 2007
1. Find the time complexity of the following functions.
a) T(N) = 2T(N/4) + 7N – 15
b) T(N) = 16T(N/3) + 3N2 + 5N + 16
c) T(N) = 8T(N/2) + 15
2. You are given a somewhat stranger recurrence T(N) = 8T(N/2) + Nlog(N).
While this is not a straightforward application of the Master Theorem, we can
use multiple applications of that theorem to make a statement on the growth rate of
T(N). Find the time complexity of T(N). Your solution will implicitly assume that
N 10, but it is possible to give the answer without mentioning this explicitly.
3. Consider the following apparently useless algorithm. Use the tools developed for
analysis of recursive algorithms to determine its time complexity.
Algorithm Silly2 ( A[1 .. N], N )
// The use of 1-based arrays does not affect the complexity
If (N > 1) Then
For J = 1 to N Do A[J]= (A[J] + [N - J]) / 2
//
N2 = N / 2 // Integer division
Silly2 ( A[1 .. N], N2 )
Silly2 ( A[(N2 + 1) .. N], (N - N2) )
//
For J = 1 to N2 Do A[J] = A[N – J] – A[J]
End If
End Algorithm
4. You are given the recurrence T(N) = 4T(N/2) + NK. What is the largest value
of exponent K such that T(N) O(N3)? Assume that K 0.
NOTE: This argument does not work for the or complexity measures.
5. Sort the list E, X, A, M by use of Selection Sort. Be sure to show enough work
to demonstrate that you are using the selection sort algorithm.
6. Sort the list E, X, A, M by use of Bubble Sort. Be sure to show enough work
to demonstrate that you are using the bubble sort algorithm.

Partial preview of the text

Download Algorithm Analysis and Design Homework Set 2 for CPSC 5115 - Prof. Edward Bosworth and more Assignments Computer Architecture and Organization in PDF only on Docsity!

CPSC 5115 Algorithm Analysis and Design

Homework Set 2 Due Thursday, September 13, 2007

  1. Find the time complexity of the following functions. a) T(N) = 2T(N/4) + 7N – 15 b) T(N) = 16T(N/3) + 3N^2 + 5N + 16 c) T(N) = 8T(N/2) + 15
  2. You are given a somewhat stranger recurrence T(N) = 8T(N/2) + Nlog(N). While this is not a straightforward application of the Master Theorem, we can use multiple applications of that theorem to make a statement on the growth rate of T(N). Find the time complexity of T(N). Your solution will implicitly assume that N  10, but it is possible to give the answer without mentioning this explicitly.
  3. Consider the following apparently useless algorithm. Use the tools developed for analysis of recursive algorithms to determine its time complexity. Algorithm Silly2 ( A[1 .. N], N ) // The use of 1-based arrays does not affect the complexity If (N > 1) Then For J = 1 to N Do A[J]= (A[J] + [N - J]) / 2 // N2 = N / 2 // Integer division Silly2 ( A[1 .. N], N2 ) Silly2 ( A[(N2 + 1) .. N], (N - N2) ) // For J = 1 to N2 Do A[J] = A[N – J] – A[J] End If End Algorithm
  4. You are given the recurrence T(N) = 4T(N/2) + NK. What is the largest value of exponent K such that T(N)  O(N^3 )? Assume that K  0. NOTE: This argument does not work for the  or  complexity measures.
  5. Sort the list E, X, A, M by use of Selection Sort. Be sure to show enough work to demonstrate that you are using the selection sort algorithm.
  6. Sort the list E, X, A, M by use of Bubble Sort. Be sure to show enough work to demonstrate that you are using the bubble sort algorithm.