We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This question is misleading and poorly specified. In quicksort the partition method does not get called recursively and the sorting is done in-place. What is described here is a version of merge sort, taking additional O(n) storage space.
There's no way to pass this question with actual quicksort, because the order of the items in the sub-arrays does not get preserved.
Quicksort 2 - Sorting
You are viewing a single comment's thread. Return to all comments →
This question is misleading and poorly specified. In quicksort the partition method does not get called recursively and the sorting is done in-place. What is described here is a version of merge sort, taking additional O(n) storage space. There's no way to pass this question with actual quicksort, because the order of the items in the sub-arrays does not get preserved.
Read a bit on quicksort on Wikipedia.
Additionally, the fact that the first item is selected as the pivot should be specified in the question, not expected to be inferred from the example.