Get in touch with us
Send us an e-mail
Question
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.
Summary
The question belongs to Computer Science, particularly to C language. The question here is about Quicksort, a sorting algorithm developed by Tony Hoare. A report on the relative run time complexity of the choice of pivot used in Quickisort algorithm has been answered in the solution.
Total Word Count 1249
Download Full Solution
My story with HwA started on a mid-term day, during my graduation as I was stuck with an economics assignment solution. From then onwards I constantly have obtained help from HwA and they have never disappointed me ever.
When it was time to submit the Time Series Assignment for my Stats course at grad school I was freaking out. I had no clear concept of the topic and hence could not do the proper research. The online time series assignment help expert at HwA was absolutely awesome and helped me write my Time Series Assignment essay in a way that I got a clear idea about the topic also.
I was having difficulty in structuring and writing the nuclear chemistry assignment on Balancing Nuclear Equations & Predicting the Product of a Nuclear Reaction. The nuclear chemistry assignment expert guided me through the process in such a way that I not only finished writing the assignment but also acquired a clear concept of the topic.
I am pursuing my masters in finance management from the Singapore Management University. Even though I have a clear idea of most of the concepts of finance from my undergraduate days, I was still looking for some guidance and help with my finance assignment. I had benefited greatly during my undergraduate days from the online finance tutor at TheReliableTutor so I decided to contact them again and since then have not looked back.
I was having a hard time keeping up with the different assignments given by the professors and soon I was looking at the approaching deadline to submit my thermal physics assignment. The online thermal physics assignment expert at HwA delivered my thermal physics assignment essay well within the deadline and helped me pass successfully.
Comments
this is a very good website
I have 50 questions for the same test your page is showing only 28
hi can you please help or guide me to answer my assignments. thanks
hi can anyone help or guide me to my assignments. thanks
This solution is perfect ...thanks
Hello Allison,I love the 2nd image that you did! I also, had never heard of SumoPaint, is something that I will have to exolpre a bit! I understand completely the 52 (or so) youtube videos that you probably watched. Sometimes they have what you want, sometimes they don't! However, it is always satisfying when you are able to produce something that you have taught yourself. Great job!Debra 0 likes
Perfect bank of solution.
great !
thanks for the quick response. the solution looks good. :)
thnx for the answer. it was perfect. just the way i wanted it.
works fine.