sln-HW02

sln-HW02 - CSE310 HW02, Solution and Grading Keys 1. (15...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE310 HW02, Solution and Grading Keys 1. (15 pt) Suppose we have two algorithms A 1 and A 2 for solving the same problem. Let T 1 ( n ) be the worst case time complexity of Algorithm A 1 and T 2 ( n ) be the worst case time complexity of Algorithm A 2. We know that T 1 (1) = 1 and T 1 ( n ) = 7 · T 1 ( n/ 2)+ f ( n ), where f ( n ) = Θ( n 2 ). We also know that T 2 (1) = 1 and T 2 ( n ) = 63 · T 2 ( n/ 4) + 30 · n 2 . Use the master method to decide T 1 ( n ). Follow all the steps as illustrated in class ( a, b, log b a , etc). a = 7, b = 2, log b a = 2 . 80735. For ± (0 , 0 . 80735), we have f ( n ) = O ( n 2 . 80735 - ± ). Therefore we have case-1 in the Master method. As a result, T 1 ( n ) = Θ( n 2 . 80735 ). Grading: +1 pt for a ; +1 pt for b ; +1 pt for log b a ; +1 pt for the correct case; +1 pt for the correct answer. Use the master method to decide T 2 ( n ). Follow all the steps as illustrated in class ( a, b, log b a , etc). a = 63, b = 4, log b a = 2 . 98864. For ± (0 , 0 . 98864), we have f ( n ) = O ( n 2 . 98864 - ± ). Therefore we have case-1 in the Master method. As a result, T 2 ( n ) = Θ( n 2 . 98864 ). Grading: +1 pt for a ; +1 pt for b ; +1 pt for log b a ; +1 pt for the right case; +1 pt for the right answer. Which algorithm is faster? Why? Since T 1 ( n ) = O ( T 2 ( n )), but T 2 ( n ) 6 = O ( T 1 ( n )), we conclude that A1 is faster.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/04/2009 for the course CSE 310 taught by Professor Davulcu,h during the Spring '08 term at ASU.

Page1 / 4

sln-HW02 - CSE310 HW02, Solution and Grading Keys 1. (15...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online