Answered step by step
Verified Expert Solution
Question
1 Approved Answer
7 Bonus! Analyzing quickSort In this bonus section you will work through the analysis of the expected running time of everybody's favorite sorting algorithm: quickSort.
Bonus! Analyzing quickSort
In this bonus section you will work through the analysis of the expected running time of everybody's favorite
sorting algorithm: quickSort. Here is some pseudocode.
Input: An integer array of length Assume for simplicity that every integer in is unique.
Base Case: If return
Choose the Pivot: Choose a random index dots, and let
Filter Around the Pivot: Let st;dots,cdotscdots and
consists all elements A which are less than ; all elements A which are greater.
Recursive calls: Let quickSort and quickSort
Output: Return where here denotes array concatenation
Computing the runtime quickSort conceptually very similar the runtime computation mergeSort,
however complications arise because the pivot chosen randomly. Let denote the expected running time
quickSort when the input array A has size Complete the following outline proving that
prove here Suppose that the smallest element that the pivot
appears this case, the length and the length and
the expected runtime the recursive calls made Step Because the pivot was
chosen randomly, the probability that indeed the smallest element for
all dots, Therefore, the expected runtime the recursive calls
Finally, choosing the pivot takes time and the filter step takes time Thus, satisfies:
This will our starting point. Also, note
Prove
Deduce
Deduce
Now iterate this bound get cdots
Finally use the fact from calculus: cdots get
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