1. Engineering
  2. Computer Science
  3. program description implement quicksort using the lomuto partitioning method with...

Question: program description implement quicksort using the lomuto partitioning method with...

Question details


Implement quicksort using the Lomuto partitioning method with the median-of-three variant for selecting a pivot element (as described in class and in the textbook.) Use a constant to determine what minimum size (and above) array to apply the median-of-three technique, and determine a good value for this constant experimentally.

You may use a Vector (C++) or an array to store your data.

C++ implementations are not required to use classes for this assignment.


The input to your program will an unspecified number of entries. Each entry is a non-negative integer containing nine (zero padded) digits ( this means that the integer may have either leading or trailing zeros), one per line. Read your input from STDIN.


Send the values, one per line, as they were input (all nine digits including leading zeroes, if any), sorted in ascending order, to STDOUT. The only output of your program is the numeric results. (i.e. don't output your name, assignment number, prompts etc.)


Once your Lomuto partition method is coded, working, and tested thoroughly, add an alternate version of the partition method that use Hoare's partitioning scheme. (You will still be using the median of three technique.) Note that if you use Hoare's partition method, your other functions might need to be modified slightly as well. Thoroughly test the revised version of the program. Your program should use the Lomuto partition method by default. Include a command line parameter ("-h") to select the Hoare partition method instead. Include analysis of your algorithm (in the same readme file) comparing both versions for a large variety of data sets. (One half of the extra credit is for the implementation and one half is for the analysis.) You will score no extra credit if both methods are not functioning properly.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution