Java Data Structures-sorting algorithm
Explain your reasoning and include an analysis of the runtimes on that type of input.
Methods: Bubble Sort, Selection Sort, Insertion Sort, Shell Sort
(b) If the elements in an input array of size 𝑁 are sorted in reverse order, list the following sorting methods in order of efficiency (most efficient to least efficient) on that type of input. Explain your reasoning and include an analysis of the runtimes on that type of input.
Methods: Bubble Sort, Selection Sort, Insertion Sort, Shell Sort
(c)If the elements in an input array of size 𝑁 are already sorted in the correct order, list the following sorting methods in order of efficiency (most efficient to least efficient) on that type of input. Explain your reasoning and include an analysis of the runtimes on that type of input. Methods: Bubble Sort, Selection Sort, Insertion Sort, Shell Sort
Problem 4 (a)Construct an array of 25 elements containing the numbers 1 through 25 for which Shell Sort, with h-values {13, 4, 1} would use many compares than usual. In other words, construct an
array that would result in a worst-case runtime. How many compares does it require to be sorted?
HINT: Although you can search for a sequence of 25 values that causes the largest amount of compares, you will have to dedicate a daunting amount of time on doing that. Instead, search for a “bad” sequence going backwards: for ℎ = 1, place the 25 values such that the algorithm must swap the values a lot of times. Repeat the process for ℎ = 4 and ℎ = 13.
(b) Describe the best-case runtime for Shell Sort and the kind of input that would result in the best-case runtime. Justify your answer.
Problem 5 (a)Show the following array as it goes through in-place Heap Sort (from smallest to largest).
{3, 4, 1, 0, 9, 2}
(b) Explain in detail the worst-case runtime of Heap Sort. Your explanation should include a summation.
(c)What is the best-case runtime for Heap Sort? Be specific about the input that would result in the best case and explain your reasoning.
Problem 6Prove by induction that the worst-case runtime of Merge Sort is O(nlog(n)).
T(n)=cnlog(n), where c is constant