Answered step by step
Verified Expert Solution
Question
1 Approved Answer
( 3 points ) A randomized quick sort works as follows. For ease of discussion we assume that the sequence we want to sort, K
points A randomized quick sort works as follows. For ease of discussion we assume that the sequence we want to sort, ~dots, is a permutation of to We randomly and uniformly pick a key from Then we partition into two subsets that has keys less than and that has keys greater than Then we recursively sort and and combine the results with to get the sorted sequence.
The number of key comparisons will always be maximized when the keys in are already sorted.
Let and be the number of keys in and respectively. The expected value of max is
The algorithm will compare two keys and at most once, so the number of key comparisons is
The probability that the algorithm will compare and is
Let The expected total number of key comparisons is jinP
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started