Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the Selection Sorter class, you should have a function that can take a passed-in array and sort its element in ascending sorted order. You

image text in transcribedimage text in transcribed

In the Selection Sorter class, you should have a function that can take a passed-in array and sort its element in ascending sorted order. You need to use the selection sort algorithm in this function. In the BubbleSorter class, you should have a function that can take a passed-in array and sort its element in ascending sorted order. You need to use the bubble sort algorithm in this function. You also need to write an interface Sorter that abstract all your sorter classes. In an- other word, your InsertionSorter, Selection Sorter, and BubbleSorter should implement your Sorter interface. In the Sorter Tester class, you should have a method that can generate an int array, where each array element is a random int. In the main method of Sorter Tester. You need to generate three random int arrays first. And then you can test if all of your three sort algorithms work properly. When I run your program, it should output like below: = SELECTION SORT = test Array 2 (before): 10, 6, 6, 10, 2, 8, 2, 2] (step 1): [2, 6, 6, 10, 10, 8, 2, 2] (step 2): [2, 2, 6, 10, 10, 8, 6, 2] (step 3): [2, 2, 2, 10, 10, 8, 6, 6] (step 4): [2, 2, 2, 6, 10, 8, 10, 6] (step 5): [2, 2, 2, 6, 6, 8, 10, 10) (step 6): [2, 2, 2, 6, 6, 8, 10, 10) (step 7): [2, 2, 2, 6, 6, 8, 10, 10) test Array2 (after): 2, 2, 2, 6, 6, 8, 10, 10] == BUBBLE SORT test Array3 (before): 5, 1, 8, 7, 7, 10, 8, 5] (step 1): [1, 5, 7, 7, 8, 8, 5, 10) (step 2): [1, 5, 7, 7, 8, 5, 8, 10) (step 3): 1, 5, 7, 7, 5, 8, 8, 10) (step 4): [1, 5, 7, 5, 7, 8, 8, 10] (step 5): 1, 5, 5, 7, 7, 8, 8, 101 (step 6): 1, 5, 5, 7, 7, 8, 8, 10 (step 7): [1, 5, 5, 7, 7, 8, 8, 10] test Array 3 (before): [1, 5, 5, 7, 7, 8, 8, 10) In the Selection Sorter class, you should have a function that can take a passed-in array and sort its element in ascending sorted order. You need to use the selection sort algorithm in this function. In the BubbleSorter class, you should have a function that can take a passed-in array and sort its element in ascending sorted order. You need to use the bubble sort algorithm in this function. You also need to write an interface Sorter that abstract all your sorter classes. In an- other word, your InsertionSorter, Selection Sorter, and BubbleSorter should implement your Sorter interface. In the Sorter Tester class, you should have a method that can generate an int array, where each array element is a random int. In the main method of Sorter Tester. You need to generate three random int arrays first. And then you can test if all of your three sort algorithms work properly. When I run your program, it should output like below: = SELECTION SORT = test Array 2 (before): 10, 6, 6, 10, 2, 8, 2, 2] (step 1): [2, 6, 6, 10, 10, 8, 2, 2] (step 2): [2, 2, 6, 10, 10, 8, 6, 2] (step 3): [2, 2, 2, 10, 10, 8, 6, 6] (step 4): [2, 2, 2, 6, 10, 8, 10, 6] (step 5): [2, 2, 2, 6, 6, 8, 10, 10) (step 6): [2, 2, 2, 6, 6, 8, 10, 10) (step 7): [2, 2, 2, 6, 6, 8, 10, 10) test Array2 (after): 2, 2, 2, 6, 6, 8, 10, 10] == BUBBLE SORT test Array3 (before): 5, 1, 8, 7, 7, 10, 8, 5] (step 1): [1, 5, 7, 7, 8, 8, 5, 10) (step 2): [1, 5, 7, 7, 8, 5, 8, 10) (step 3): 1, 5, 7, 7, 5, 8, 8, 10) (step 4): [1, 5, 7, 5, 7, 8, 8, 10] (step 5): 1, 5, 5, 7, 7, 8, 8, 101 (step 6): 1, 5, 5, 7, 7, 8, 8, 10 (step 7): [1, 5, 5, 7, 7, 8, 8, 10] test Array 3 (before): [1, 5, 5, 7, 7, 8, 8, 10)

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

Step: 3

blur-text-image

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

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions