Question
Write an application that determines the performance of a sort algorithm for integers based on counting the number of comparisons. Create an array of 500
Write an application that determines the performance of a sort algorithm for integers based on counting the number of comparisons.
Create an array of 500 random integers using the Random class. Next sort this array of integers using Quick Sort and save the result in a new array.
Create a DemoProgram that will pick a random integer from the above array and run a sequential search on the unsorted array and a binary search on the sorted array to find this integer. Keep track of the number of comparisons for each sort.
Do the above 10 times, printing out the comparisons each time and then printing out the average number of comparisons overall for each search algorithm.
Please make sure you comment your code thoroughly.
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