Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement in Java two versions of the Quicksort algorithm: HOARE - QUICKSORT and Lomuto - Quicksort. Please follow the pseudocode for these two algorithms discussed
Implement in Java two versions of the Quicksort algorithm: HOAREQUICKSORT and LomutoQuicksort. Please follow the pseudocode for these two algorithms discussed in class, which can be found on the Module Part lecture slides. Please make sure that your implementations will correctly sort any input array into ascending nondecreasing order.
For each of these two versions of Quicksort algorithms, please add two static counters to your program, one to track the number of key comparisons KCs and the other to track the number of swaps. The output of your program should include the total number of KCs and the total number of swaps made by each Quicksort algorithm. To check your program's correctness, you can run it on small input arrays, such as the examples we discussed in class.
Complete the Following Tasks:
a
Programming. Submit one zip file including all source files of your program for grading. You will get points for this part if your program does not compile.
b
Run your program multiple times on different input arrays as outlined in the first two columns of the following table. Fill in the table at the top of the following page with data obtained from your program's outputs. Additionally, include screenshots capturing your program's output for each run.
c
Based on the results you obtained in part b does one version of the Quicksort algorithm always perform better better means with fewer KCs AND also fewer swaps than the other? If your answer is no in which of the four cases does one Quicksort algorithm perform better than the other?
tableInput array,HoareQuicksort,LomutoQuicksortArray elements,Size,# of # of Swaps,# of # of Swapstable Distinct numbers inascending ordertable Distinct numbers indescending order All the same number,table Random numbers between and inclusive
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started