Question

In: Computer Science

out of the following four: 1.Bubble sort 2. Insertion sort 3. Quicksort 4. Mergesort a. Which...

out of the following four:

1.Bubble sort
2. Insertion sort
3. Quicksort
4. Mergesort

a. Which sorting methods perform best and worst for data sizes ≥ 25,000 when
the input data is random?
b. Which sorting methods perform best and worst for data sizes ≥ 25,000 when
the input data is 90% sorted?
c. Which sorting methods perform best and worst for data sizes ≥ 25,000 when
the input data is reverse sorted?
d. Which sorting methods perform best and worst for data sizes < 25,000 when
the input data is random?
e. Which sorting methods perform best and worst for data sizes < 25,000 when
the input data is 90% sorted?
f. Which sorting methods perform best and worst for data sizes <25,000 when the
input data is reverse-sorted?
g. What is the relationship between the running time and the data size for each
of the sorting methods when the input data is random? (Try to come up with a function –
need not be ‘exact’, but close)
 Bubble sort
 Insertion sort
 Mergesort
 Quicksort
h. Conclude which sorting method is better suited for data size >25,000 and under
what input data pattern (random, almost sorted and reversely sorted)

Solutions

Expert Solution

The time complexity of the sorting algorithm listed in different scenario are:

Algorithm

Random

Sorted

ReverseSorted

Bubble n2 n2 n2
Insertion n2 n n2
Quick n logn n2 n2
Merge n logn n logn n logn

The graph for n, n2, n logn are give below:

It is clear from graph that there is no significant changes in nature of graph at n = 25000 and so, the nature of algorithm would be same.

It is noted that  

Now, Answering the question based on above results and table.

a) and d) For random input data,

Best: QuickSort, MergeSort
Worst: InsertionSort, BubbleSort.

b) and e) For Sorted (90% sorted is approx same as completely sorted)

Best: InsertionSort,
Worst: QuickSort, BubbleSort.

c) and f) For Reverse Sorted

Best: MergeSort
Worst: InsertionSort, BubbleSort, QuickSort.

The answer to question g) is already given in table.

h) Insertion Sort have time complexity O(n) for almost sorted (or sorted) data set. Hence it is most suited.

Hope it helps.


Related Solutions

out of the following four: 1.Bubble sort 2. Insertion sort 3. Quicksort 4. Mergesort a. Which...
out of the following four: 1.Bubble sort 2. Insertion sort 3. Quicksort 4. Mergesort a. Which sorting methods perform best and worst for data sizes ≥ 25,000 when the input data is random? b. Which sorting methods perform best and worst for data sizes ≥ 25,000 when the input data is 90% sorted? c. Which sorting methods perform best and worst for data sizes ≥ 25,000 when the input data is reverse sorted? d. Which sorting methods perform best and...
give a good explanation of Bubble sort, Insertion sort, Selection sort, and Quicksort.
give a good explanation of Bubble sort, Insertion sort, Selection sort, and Quicksort.
For this assignment, find out how to do a bubble sort, selection sort, or insertion sort...
For this assignment, find out how to do a bubble sort, selection sort, or insertion sort in Java. You have the option to choose but you must label (with comments) the algorithm you choose to implement. Convert that algorithm to a generic algorithm and constraint it to only using numerics. Your method should accept an array as a parameter and sort the content of the array. If you wish, you can throw an exception if the contents of the array...
Sort the following set of numbers using bubble sort, insertion sort, and selection sort. Show the...
Sort the following set of numbers using bubble sort, insertion sort, and selection sort. Show the process step-by-step, and find the time complexity in Big-O notation for each method. For sorting, use ascending order. 49, 7, 60, 44, 18, 105
2 real-time examples on the Insertion sort, Bubble sort, Selection sort, Quick sort, Shell sort, Merge...
2 real-time examples on the Insertion sort, Bubble sort, Selection sort, Quick sort, Shell sort, Merge sort, Radix sort, Bucket sort, and Counting sort.
come up with at least 2 real-time examples on the Insertion sort, Bubble sort, Selection sort,...
come up with at least 2 real-time examples on the Insertion sort, Bubble sort, Selection sort, Quick sort, Shell sort, Merge sort, Radix sort, Bucket sort, and Counting sort.
come up with at least 2 real-time examples on the Insertion sort, Bubble sort, Selection sort,...
come up with at least 2 real-time examples on the Insertion sort, Bubble sort, Selection sort, Quick sort, Shell sort, Merge sort, Radix sort, Bucket sort, and Counting sort.
Can someone implement the following in Java? Quicksort with switching to Insertion sort when the number...
Can someone implement the following in Java? Quicksort with switching to Insertion sort when the number of elements in the subarray is less than or equal to 2% of the original number Requirements: 1) functions from standard libraries implementing Quicksort are NOT allowed;
Runtime complexity of Insertion sort and Mergesort algirthms- and analysis with different size of inputs: In...
Runtime complexity of Insertion sort and Mergesort algirthms- and analysis with different size of inputs: In python Implement a method to sort a given array using the merge sort algorithm. Write a driver program to test the merge sort algorithm and insertion sort algorithm for the arrays of varying lengths provided.. Ex: array lenth 100, Array lenth 1000 etc. Compare the execution time of merge sort with insertion sort. Make sure you use the same array to compare the performance....
Sorting – Insertion Sort Sort the list 0, 3, -10,-2,10,-2 using insertion sort, ascending. Show the...
Sorting – Insertion Sort Sort the list 0, 3, -10,-2,10,-2 using insertion sort, ascending. Show the list after each outer loop. Do his manually, i.e. step through the algorithm yourself without a computer. This question is related to data structure and algorithm in javascript (.js). Please give your answer keeping this in your mind.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT