Write a client program Client Sorting and in the main method:
1. Call a method, SelectionSorter() that accepts an integer array as a parameter and sorts the elements in the array using the selection sort algorithm where it picks the maximum value in the array in each pass. Print the array before it is sorted in the main method, then after it is sorted in SelectionSorter().
2. Call a method, BubbleSorter that accepts an integer array as a parameter and sorts the elements in the array in descending order (highest number first, then the second highest and so on) using the bubble sort algorithm. Print the array before it is sorted in the main method, then after it is sorted in BubbleSortero.
3. Call a method, InsertSorter() that accepts an integer array as a parameter and sorts the elements in the array using the insertion sort algorithm. Print the array before it is sorted in the main method, then after it is sorted in InsertSortero.

Answers

Answer 1

Answer:

Explanation:

The following code is written in Java. It creates a method for each of the sorting algorithms and one method to reset the array and print the original, so that all algorithms can be tested with the same array.The entire program code is below.

import java.util.Scanner;

class Brainly {

   static int[] arr;

   public static void main(String[] args) {

       // Print Unsorted Array and Call Selection Sort and print

       resetArray();

       SelectionSorter(arr);

       System.out.print("\nSelection Sort Array: ");

       for (int x : arr) {

           System.out.print(x + ", ");

       }

       //Reset Array and call Bubble Sort and print

       System.out.println('\n');

       resetArray();

       BubbleSorter(arr);

       System.out.print("\nBubble Sort Array: ");

       for (int x : arr) {

           System.out.print(x + ", ");

       }

       //Reset Array and call Insert Sort and print

       System.out.println('\n');

       resetArray();

       InsertSorter(arr);

       System.out.print("\nInsert Sort Array: ");

       for (int x : arr) {

           System.out.print(x + ", ");

       }

   }

   public static void resetArray() {

       arr = new int[]{10, 14, 28, 11, 7, 16, 30, 50, 25, 18};

       System.out.print("Unsorted Array: ");

       for (int x : arr) {

           System.out.print(x + ", ");

       }

   }

   public static void SelectionSorter(int[] arr) {

       for (int i = 0; i < arr.length - 1; i++) {

           int index = i;

           for (int j = i + 1; j < arr.length; j++) {

               if (arr[j] < arr[index]) {

                   index = j;//searching for lowest index

               }

           }

           int smallerNumber = arr[index];

           arr[index] = arr[i];

           arr[i] = smallerNumber;

       }

   }

   static void BubbleSorter(int[] arr) {

       int n = arr.length;

       int temp = 0;

       for (int i = 0; i < n; i++) {

           for (int j = 1; j < (n - i); j++) {

               if (arr[j - 1] > arr[j]) {

                   //swap elements

                   temp = arr[j - 1];

                   arr[j - 1] = arr[j];

                   arr[j] = temp;

               }

           }

       }

   }

   public static void InsertSorter(int arr[]) {

       int n = arr.length;

       for (int j = 1; j < n; j++) {

           int key = arr[j];

           int i = j - 1;

           while ((i > -1) && (arr[i] > key)) {

               arr[i + 1] = arr[i];

               i--;

           }

           arr[i + 1] = key;

       }

   }

}

Write A Client Program Client Sorting And In The Main Method: 1. Call A Method, SelectionSorter() That

Related Questions

You are a web designer, and a client wants you to create a website for their new business. Discuss what you would talk about with the client to ensure they were getting the website they wanted. What questions would you ask the client? What information would you need from the client?

Answers

Answer:

1. for what purpose?

2. the pattern design of web

3. what the client wants to add in the web

4. his contact number and email

5. the logo of the business

6. talk about pricing  

Explanation:

Other Questions
Please Help! My question is attached below. Mother of Exiles.The woman with a torch is the Statue of Liberty. This lightning torch stands for her power as a friend to anyone who comes to America.Which phrase from the selection helps the reader understand the meaning of "exiles"? Write the equation of the line that passesthrough the points (-6,3) and (3,-9) Explain why it is important for businesses to understand their history and how that history sets limitations?PLEASE ANSWER WHAT IS THE MEDIAN I WILL GIVE BRAINIEST What is the surface area of the figure?below is a picture of the figure and the answer optionsPls help me I'm DESPERATE A cylindrical vessel is pressurized to 1.7 MPa. The structure on which the vessel rests becomes damaged, resulting in uneven support that causes a twisting moment T0 of 8 106 N-m on the vessel. The vessel has an outer diameter of 2.5 m and a wall thickness of 50 mm. The steel wall has a uniaxial yield strength of 600 MPa. Determine the factor of safety with respect to yielding (a) assuming a maximum shear stress yield criterion and (b) assuming a von Mises yield criterion. what would be the effect of bringing a negatively charged metal ball near an iron bar 1. Tell me if each of the following is True or False A. Angles EOD and DOC are Vertical Angles. B. Angles FOD and Angle DOC are adjacent C. Angles FOD and AOC are equal D. The sum of the measurements of Angles of AOC and BOC and equal to FOD E. FOE and DOD are completely Angles F. Angles FOA, AOB, and AOC are Supplementary Angles Your psychology professor has announced that the next test will assess your understanding of sensation and perception. When you receive the test, however, you find very few questions actually related to these topics. In this instance, you would be most concerned about the ______________ of the test. Reliability Predictive validity Standardization Content validity Write a unit rate for the situation. Show all work!12 goals in 3 hoursHELP THIS IS DUE IN 12 MINUTES! Find the frequency and wavelength of the wave below, assuming it has a speed of 30 m/s How to fall asleep faster? At least 10 You have $20 to spend for cupcakes. If each cupcake costs $4, write and solve an inequality to show the maximum number of cupcakes you can buy. Qu tipo de literatura propugnaban los escritores neoclsicos? Which known figures make up this unknown figure? Two identical bulbs in parallel in a radio create a total resistance of 15 ohms in the circuit. What's the resistance of each of the bulbs A. 10 ohms B. 7.5 ohms C. 45 ohms D. 30 ohms SOMEONE PLEASE HELP ME WITH PASSIVE VOICE QUICKLY 1. Las galletas _____ por mi madre. A. fui hechaB. fue hecha C. fueron hechasD. fue hechas 2. El vestido ______ por el actor famoso. A. fue llevado B. fue llevadaC. fui llevadoD. fueron llevado3. Los libros ____ por Sandra Cisneros. A. fue escrito.B. fue escrita.C. fueron escritoD. fueron escritos 4. La mesa ____ por mis hermanos. A. fueron puestaB. fueron puestoC. fue puestaD. fue puesta Do you think music describes a person? What would your music say about you? A new laptop is on sale for $550 dollars. To pay for it you place it on your credit card which charges 12% percent interest each month