
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The concept of order statistics and the selection problem, which involves finding the kth smallest element in a data set. the partition algorithm and its runtime analysis, as well as the importance of choosing a good pivot. The document also introduces the median-of-medians algorithm for finding a good pivot and analyzes its recurrence.
What you will learn
Typology: Thesis
1 / 40
This page cannot be seen from the preview
Don't miss anything!
โ
โ Can submit by Monday at 2:15PM using one late period. โ
โ (^) Play around with divide-and-conquer algorithms and recurrence relations! โ Covers material up through and including today's lecture.
โ
โ A problem halfway between searching and sorting. โ
โ (^) A nonobvious algorithm with a nontrivial runtime. โ
โ (^) Solving recurrences the Master Theorem can't handle.
โ Given a collection of data, the k th order statistic is the k th smallest value in the data set. โ For the purposes of this course, we'll use zero-indexing, so the smallest element would be given by the 0 th order statistic. โ To give a robust definition: the k th order statistic is the element that would appear at position k if the data were sorted.
โ
โ
โ Sort the array. โ Return the element at the k th position. โ
โ
โ Given an input array, a partition algorithm chooses some element p (called the pivot ), then rearranges the array so that โ All elements less than or equal to p are before p. โ (^) All elements greater p are after p. โ p is in the position it would occupy if the array were sorted. โ The algorithm then returns the index of p. โ We'll talk about how to choose which element should be the pivot later; right now, assume the algorithm chooses one arbitrarily.
โ There is a close connection between partitioning and the selection problem. โ Let k be the desired index and p be the pivot index after a partition step. Then: โ If p = k , return A[ k ]. โ If p > k , recursively select element k from the elements before the pivot. โ If p < k , recursively select element ( k โ p โ 1) from the elements after the pivot.
โ
โ Check the Problem Set Advice handout for an outline of an algorithm to do this. โ
โ
โ The runtime of our algorithm depends on our choice of pivot. โ In the best-case, if we pick a pivot that ends up at position k , the runtime is ฮ( n ). โ In the worst case, we pick always pick pivot that is the minimum or maximum value in the array. The runtime is given by this recurrence:
โ
2
โ
โ
โ
โ
โ (^) (Those sizes don't have to be the same, though.)
โ
โ Recursively calls itself on the first 2/3 of the array. โ Runs a partition step. โ Then, either immediately terminates, or recurses in a piece of size n / 3 or a piece of size 2 n / 3. โ
โ
โ
โ
โ a = 2 , b = 3 / 2 , and d = 1.
3 / 2
log 3 / 2 2