Question: Workout (Trace) the following sorting algorithms for the array given below. Clearly show array A and other variables at each step as you run each
Workout (Trace) the following sorting algorithms for the array given below. Clearly show array A and other variables at each step as you run each of these sorting algorithms.
A={22, 91, 24, 78, 6, 89, , 98, 99}
a) Selection sort
b) Merge sort
c) Quicksort
Analyzing sorting algorithm for time and space complexity
a) What is the time complexity of an algorithm?
b) What is space complexity of an algorithm?
c) Suppose you take a size n array (assume that n = 2m), and start dividing the array into halves
until you have one element in the bottom level. Show that the height of the tree structure
created by the above process has the height m and m=log (n).
d) Compare and contrast above three sorting algorithm based on time and space complexity.
Consider the best-case, worst-case, and average case scenarios.
Experimentally proving the time complexity of sorting algorithms. During lectures we have discussed how to determine the time run a program. Starting from 10000 elements until 60000 elements increment by 10000, create an integer array with random numbers and apply the above three sorting algorithms and the Java built in sorting algorithm Arrays.sort() separately to sort the array and time it. Then fill the following table. Using Microsoft excel, plot the times against the size of the array and see if part (d) matches with your data.

a) submit your code for the program that record running times of above sorting algorithms
b) completed table above
c) graph that shows array size vs. time for each sorting algorithm.
Arrays.sort() Array Size 10000 20000 30000 40000 50000 60000 Selection Sort Merge sort Quicksort
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
