What is the best-case running time of QUICKSORT? Please provide the recurrence for the best-case scenario and solve it.

Homework 2
This homework has two parts with different deadlines. Please read the instructions at the beginning of each part
carefully.
1 Part I – Due: October 12 11:59pm ET
All the answers should be included in a single pdf file. For this homework, you can scan your handwritten answers
and include the clear pictures. However, you must make sure that your answers can be read in these pictures in the
PDF file. Illegible answers will receive 0 points.
For Part I submission, if your NetID is ab123, you should submit the following file to Canvas: hw2-part1-ab123.pdf.
Problem 1.  Is an array that is in sorted order  a min-heap? Please provide your reasoning.
Problem 2. () llustrate the process of MAX-HEAPIFY(A,3) on array A = [92, 82, 25, 72, 77, 88, 76,
47, 60, 19, 34, 22, 43, 17, 23] using the “binary tree view” illustrated as examples in the slides.
Problem 3. Illustrate the process of BUILD-MAX-HEAP on array A = [48, 14, 79, 90, 64, 83, 79,
12, 100] by showing A after each iteration of the for loop (not the “binary tree view” as the problem above).
BUILD-MAX-HEAP(A, n)
1 A.heap_size = n
2 for i = bn/2c downto 1
3 MAX-HEAPIFY(A, i)
Problem 4. Using example in the slides as model, please illustrate the process of HEAPSORT with
A = [50, 30, 37, 22, 7, 9, 5]. Here, BUILD-MAX-HEAP has already been executed, and A is a max-heap.
Problem 5.  Illustrate the process of sorting the array using QUICKSORT. Please provide every step of how the array changes and the pivot of partitioning.
Problem 6.
(a) What is the best-case running time of QUICKSORT? Please provide the recurrence for the best-case scenario and solve it.
(b) Give a concrete example of an array A with n ≥ 5 that exhibits the best-case behavior.
Problem 7.
(a) What is the worst-case running time of QUICKSORT? Please provide the recurrence for the worst-case scenario and solve it.
(b) Give a concrete example of an array A with n ≥ 5 that exhibits the worst-case behavior.
Problem 8.COUNTING-SORT includes four for loops. Given array A = [1, 3, 5, 4, 1, 6, 2, 1, 3, 2, 5, 3],
please show the following for COUNTING-SORT(A, 12, 6):
(a) contents of array C after the first for loop
(b) contents of array C after the second for loop
(c) contents of array C after the third for loop
(d) contents of array C after the fourth for loop
(e) contents of array B after the fourth for loop

Last Completed Projects

topic title academic level Writer delivered
© 2020 EssayQuoll.com. All Rights Reserved. | Disclaimer: For assistance purposes only. These custom papers should be used with proper reference.