
Investigation: Sort Wars If quicksort is so quick, why bother with anything else? If bubble sort is so bad, why even mention it? For that matter, why are there so many different sorting algorithms? Your task is to investigate these and other questions in relation to the algorithms selection sort, insertion sort, merge sort, and quicksort
Task
1. Explain the selection sort, insertion sort (fast or slow), merge sort, and quicksort algorithms in such a way that an intelligent lay person would be able to understand how they work. Whilst you may wish to consult the lecture notes to re-familiarise yourself with the inner workings of each
You may find it helpful to consider how you would explain the algorithms to your friend studying a non-IT degree. One approach would be to treat each algorithm as if it were a game for which you need to define the rules. For example, here is how you could describe the bubble sort algorithm as if it were a game of solitaire played with a deck of cards that contain the values to process
2. Write a set of guidelines for each algorithm to help someone decide which one would be most appropriate for a particular situation. Include in your guidelines a description of the advantages and disadvantages, together with an indication as to why those characteristics apply, and an explanation of the running cost (in Big-O notation). Your goal is to provide enough information so that someone unfamiliar with the inner workings of each algorithm would be able to decide which one is right for them. For example, if someone was considering using counting sort to sort a collection of values then the following brief information could help them decide if it was appropriate or not.
Algorithm Counting Sort
Description Count the number of times each different value appears, then overwrite the values in lowest-to-highest order, with each value repeated according to the counts
Advantages • Usually faster than any of the comparison-based sorts. • Algorithmic complexity is O(n + k), irrespective of the data order, where n is the list length and k is the number of distinct values that might occur. Typical case is where k is much less than n, in which case the cost is O(n).
• Simple to code
Disadvantages • Only usable where the values to be sorted can be used to index an array of value counts, which usually means the values are integers over a small range. In other words, the algorithm cannot be used to sort common non-integral values such as strings and floats, and it is inappropriate even for integers if the range of values is large.
• Requires an auxiliary array (to store the counts) of size equal to the number of different possible sort values. If the range of values is large, the cost of allocating and maintaining this array could be significant.
When to use… If your circumstances allow, it is hard to beat this algorithm, but because it places very tight restrictions on the nature of the data to sort, you will often have to choose another approach.

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- cite one real-world example where we use bubble sort and selection sort.arrow_forwardWhy might you combine a sorting algorithm with another algorithm?Write at least two paragraphs explaining and answering the above- evaluate the strengths, weaknesses, other possible applications that can be made.arrow_forwardThis question concerns the following sorting algorithm (attachment). (b) Consider the operation of SORT on a list of length N. How many comparisons in line 4 take place when i = 1 and when i = N-1? (c) How many comparisons take place in total? Show your working. You may use the result 1+2+...+n=n[(n+1)/2] (d) Based on the analysis above, or otherwise, what is the worst, best and average- case time complexity of SORT? Explain your answer.arrow_forward
- (b) Explain in your own words why even the more efficient versions of bubble sort are considered to be slow algorithms. Illustrate your answer using the example data: {17, 15, 11, 13}arrow_forwardPlease justify your answer: Some sorting algorithms require extra space, apart from the space needed for the original array that needs to be sorted. Which one of the following statements on the space usage of sorting algorithms is correct? a.) A Heapsort for sorting an array of size N requires an amount of extra space proportional to N. b.) Insertion Sort for sorting an array of size N requires an amount of extra space proportional to N. c.) Merge sort for sorting an array of size N requires an amount of extra space proportional to N. d.) Quicksort for sorting an array of size N requires an amount of extra space proportional to N. e.) None of the abovearrow_forwardIs searching with pre-sorting usually worse or better than sequential search in time complexity? [Select] Which is more useful in practice since we usually do more lookups after a one-time sorting? [Select] What kind of search do we apply for its efficiency? [Select] [Select] binary search decimal search How much time does it take for the worst case whe [Select]arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





