This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 1 Problem of the Day Assume that n= 2 k+1-1. Solve this recurrence using repeated substitution showing all your work: T(n)= (n+1) + 2 T((n-1)/2), T(1)=1. Hint: These are a lot easier to solve if you express the equations in terms of k before starting. For more of a challenge, solve this one: T(n)= n + 2 T((n-1)/2), T(1)=1. 2 Quicksort A well-known sorting algorithm developed by C. A. R. Hoare in 1962 that, on average, makes (nlogn) (big O notation) Θ comparisons to sort n items. However, in the worst case, it makes (n Θ 2 ) comparisons . Typically, quicksort is significantly faster in practice than other (nlogn) algorithms, because its Θ inner loop can be efficiently implemented on most architectures, and in most real-world data, it is possible to make design choices which minimize the probability of requiring quadratic time....
View Full Document
- Spring '10
- Sort, void quicksort, public class Quicksort