quiz1_sol

# quiz1_sol - Introduction to Algorithms Massachusetts...

This preview shows pages 1–5. Sign up to view the full content.

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

View Full Document
2 Handout 14: Quiz 1 Solutions Problem 1. Asymptotic Running Times [12 points] (4 parts) For each algorithm listed below, give a recurrence that describes its worst-case running time, and give its worst-case running time using -notation. You need not justify your answers. (a) Binary search Solution: T ( n ) = T ( n/ 2) + (1) = (lg n ) (b) Insertion sort Solution: T ( n ) = T ( n 1) + ( n ) = ( n 2 )
3 Handout 14: Quiz 1 Solutions (c) Strassen’s algorithm n lg 7 ) Solution: T ( n ) = 7 T ( n/ 2) + ( n 2 ) = ( (d) Merge sort Solution: T ( n ) = 2 T ( n/ 2) + ( n ) = ( n lg n )

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

View Full Document
4 Handout 14: Quiz 1 Solutions Problem 2. Substitution Method [7 points] Consider the recurrence T ( n ) = T ( n/ 2) + T ( n/ 4) + n , T ( m ) = 1 for m 5 . Use the substitution method to give a tight upper bound on the solution to the recurrence using O -notation. Solution:
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/03/2009 for the course CS 6.033 taught by Professor S during the Fall '09 term at MIT.

### Page1 / 15

quiz1_sol - Introduction to Algorithms Massachusetts...

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

View Full Document
Ask a homework question - tutors are online