Question: c) Suppose you take a size n array (assume that n = 2m), and start dividing the array into halves until you have one element
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.
3. 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.
| Array Size | Selection Sort | Merge sort | Quick Sort | Arrays.Sort() |
| 10000 | ||||
| 20000 | ||||
| 30000 | ||||
| 40000 | ||||
| 50000 | ||||
| 60000 | ||||
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
