Answered step by step
Verified Expert Solution
Link Copied!

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: HOARE-QUICKSORT and Lomuto-Quicksort. Please follow the pseudocode for these two algorithms discussed in class, which can be found on the Module 2- Part 2 lecture slides. Please make sure that your implementations will correctly sort any input array into ascending (non-decreasing) 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 0 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 case(s) does one Quicksort algorithm perform better than the other?
2
\table[[Input array,Hoare-Quicksort,Lomuto-Quicksort],[Array elements,Size,# of KCs,# of Swaps,# of KCs,# of Swaps],[\table[[(1) Distinct numbers in],[ascending order]],100,,,,],[1,000,,,,],[10,000,,,,],[\table[[(2) Distinct numbers in],[descending order]],100,,,,],[1,000,,,,],[10,000,,,,],[(3) All the same number,100,,,,],[1,000,,,,],[10,000,,,,],[\table[[(4) Random numbers between],[1 and 100,000, inclusive]],100,,,,],[1,000,,,,],[10,000,,,,]]
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

2. How should this be dealt with by the organisation?

Answered: 1 week ago

Question

explain what is meant by the term fair dismissal

Answered: 1 week ago