The quicksort algorithm was developed in 1960 by tony hoare


Problem:

Task

The quicksort algorithm was developed in 1960 by Tony Hoare while in the Soviet Union, as a visiting student at Moscow State University. At that time, Hoare worked in a project on machine translation for the National Physical Laboratory. He developed the algorithm in order to sort the words to be translated, to make them more easily matched to an already-sorted Russian-to-English dictionary that was stored on magnetic tape. Quicksort is a divide and conquer algorithm. Quicksort first divides a large list into two smaller sub-lists: the low elements and the high elements. Quicksort can then recursively sort the sub-lists.

The steps are:

1. Pick an element, called a pivot, from the list.

2. Reorder the list so that all elements with values less than the pivot come before the pivot, while  all elements with values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation.

3. Recursively sort the sub-list of lesser elements and the sub-list of greater elements.

The base case of the recursion are lists of size zero or one, which never need to be sorted.

Choice of pivot

In very early versions of quicksort, the leftmost element of the partition would often be chosen as the pivot element. Unfortunately, this causes worst-case behavior on already sorted arrays, which is a rather common use-case. The problem was easily solved by choosing either a random index for the pivot, choosing the middle index of the partition or (especially for longer partitions) choosing the median of the first, middle and last element of the partition for the pivot (as recommended by R. Sedgewick). Selecting a pivot element is also complicated by the existence of integer overflow. If the boundary indices of the subarray being sorted are sufficiently large, the naïve expression for the middle index, (left + right)/2, will cause overflow and provide an invalid pivot index. This can be overcome by using, for example, left + (right-left)/2 to index the middle element, at the cost of more complex arithmetic. Similar issues arise in some other methods of selecting the pivot element.

Task Requirement

You are required to conduct an empirical experiment to investigate the relative run time complexity of the choice of pivot on the quicksort algorithm.  You will implement three such pivot finding algorithm and evaluate their performances.  You will be required to document your experiment using the following standards.

1.  Prepare a journal ready article of between 5 and 6 pages detailing your empirical study.

2.  Be sure to design your experiment such that it exhibit validity and is robust.

Additional Information:

This question is it from Computer Science, particularly to C language. The question here is about Quicksort, a sorting algorithm developed by Tony Hoare. A report upon relative run time complexity of choice of pivot used in Quickisort algorithm has been answered in the solution.

Total Word Limit: 1249 Words

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: The quicksort algorithm was developed in 1960 by tony hoare
Reference No:- TGS01110001

Now Priced at $45 (50% Discount)

Recommended (99%)

Rated (4.3/5)