quiz1_practicsol

# quiz1_practicsol - Introduction to Algorithms Massachusetts...

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

Introduction to Algorithms 12 March 2002 Massachusetts Institute of Technology 6.046J/18.410J Professors Piotr Indyk and Charles E. Leiserson Quiz 1 Solutions Quiz 1 Solutions These are the quiz solutions The mean for this quiz was: 65.3 The standard deviation was: 13.2 Problem Points Grade 1 20 2 32 3 22 4 16 Total 90 Name:

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

View Full Document
2 6.046J/18.410J Quiz 1 Solutions Name Problem 1. Recurrences [20 points] Solve the following recurrences (provide only the () bounds). You can assume T ( n ) = 1 for n smaller than some constant in all cases. You do not have to provide justiﬁcations, just write the solutions. T ( n ) = T ( n/ 7) + 1 T ( n ) = (log n ) Master’s Theorem, case 2 T ( n ) = 3 T ( n/ 3) + n T ( n ) = ( n log n ) Master’s Theorem, case 2 T ( n ) = 5 T ( n/ 5) + n log n T ( n ) = ( n log 2 n ) Extended Master’s Theorem, case 2 T ( n ) = 10 T ( n/ 3) + n 1 . 1 T ( n ) = ( n log 3 10 ) Master’s Theorem, case 1
3 6.046J/18.410J Quiz 1 Solutions Name Problem 2. True or False, and Justify [32 points] (8 parts) Circle T or F for each of the following statements to indicate whether the statement is true or false, respectively. If the statement is correct, brieﬂy state why. If the statement is wrong, explain why. Your justiﬁcation is worth more points than your true-or-false designation. T F The solution to the recurrence log n T ( n ) = T ( n/ 3) + T ( n/ 6) + n is T ( n ) = ( n log n ) (assume T ( n ) = 1 for n smaller than some constant c ). True . First because of the n log n term, T ( n ) n log n . To obtain an upper bound, one can argue that T ( n ) can be shown to be non-decreasing and that an upper bound can be found by solving the recurrence U ( n ) = 2 U ( n/ 3) + n log n , which by the master method leads to U ( n ) = O ( n log n ) . Putting the upper and lower bounds together, we get log n ) . T ( n ) = ( n T F Radix sort works in linear time only if the elements to sort are integers in the range { 1 . . . cn } , for some c = O (1) . False . Radix sort also works in linear time if the elements to sort are integers in the range { 1 , . . . , n d } for any constant d . Note . On page 172 of CLRS, it is shown that radix sort runs in ( d ( n + k )) to sort n d -digit numbers with each digit in the range 0 to k 1 . If we take k = n and d = O (1) , d the running time is O ( n ) , but with d digits in base n , we get a range of n . The main mistake that many people did was to assume that digits were always between 0 and 9.

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

View Full Document
4 6.046J/18.410J Quiz 1 Solutions Name T F There exists a comparison-based sorting algorithm that can sort any 6-element array using at most 9 comparisons. False . A decision tree for sorting a 6-element array has to have at least 6! = 720 leaves, but if we perform at most 9 comparisons, we can get at most 2 9 = 512 leaves which is less than 720.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 01/20/2012 for the course CS 6.006 taught by Professor Erikdemaine during the Fall '08 term at MIT.

### Page1 / 9

quiz1_practicsol - 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