Question 2 | Computer Science homework help

 

 Complete Self-Check #1 within the “Exercises for Section 8.9” subsection in Section 8.9 “Quicksort” of Ch. 8, “Sorting” in Data Structures: Abstraction and Design Using Java

 Submit your assignment to the Assignment Files tab. 

Self-Check

#1. Trace the execution of quicksort on the following array, assuming that the first item in each subarray is the pivot value. Show the values of first and last for each recursive call and the array elements after returning from each call. Also, show the value of pivot during each call and the value returned through pivIndex. How many times is sort called, and how many times is partition called?55 50 10 40 80 90 60 100 70 80 20 50 22

  

Complete the following Review Questions within “Exercises for Sections 8.11” subsection in Section 8.11, “The Dutch National Flag” of Ch. 8, “Sorting” in Data Structures: Abstraction and Design Using Java

 Submit your pseudocode response to the Assignment Files tab 

  • Review Question #1
  • Review Question #3
  • Review Question #4

#1. When does quicksort work best, and when does it work worst?

#3. What is the purpose of the pivot value in quicksort? How did we first select it in the text, and what is wrong with that approach for choosing a pivot value?

#4. For the following array 30 40 20 15 60 80 75 4 20
show the new array after each pass of insertion sort and selection sort. How many comparisons and exchanges are performed by each?