I'm practicing measuring timing for algorithms and I wanted to test different timings for QuickSort. I'm trying to write a function that takes a sorted array of length n as input and generates an optimal array for QuickSort with the first element as pivot but I'm having trouble. Is there any simple way to write this function without using trees or somesuch?
Asked
Active
Viewed 69 times
1
-
For a quicksort using Hoare partition scheme, then all elements of the same value results in optimal splitting (50% 50% splits), although needless swapping of elements == pivot will occur (cache will reduce this overhead). – rcgldr Jan 20 '20 at 10:39
-
To find such an array, it is important to have the details of the quicksort algorithm. Even knowing that the pivot is the first element, leaves open whether the pivot is considered part of the left or right partition, after the swaps have been done. Can you provide the code for the quicksort algorithm you have to deal with? – trincot Jan 20 '20 at 14:38
-
Why would you not want to use trees? The relation between [quicksort and binary search trees](https://stackoverflow.com/a/45245139/1377097) is quite natural. – beaker Jan 20 '20 at 18:19