emiliogutierrez
05.09.2020 •
Social Studies
What is the central idea of the passage?
Solved
Show answers
More tips
- F Food and Cooking How to Properly Cook Buckwheat?...
- F Food and Cooking How Many Grams Are In a Tablespoon?...
- L Leisure and Entertainment Carving: History and Techniques for Creating Vegetable and Fruit Decorations...
- P Photography and Videography How to Choose the Perfect Photo Paper for Your Images?...
- H Health and Medicine What vaccines do children need?...
- H Health and Medicine Reasons for the Appearance of Warts: Everything You Need to Know...
- A Art and Culture How to Learn Screaming: Step-by-Step Guide for Beginners...
- H Health and Medicine Contraceptive Pills After 35: The Importance Of Choosing The Right Medication...
- C Computers and Internet How to Choose a Monitor?...
- H Horoscopes, Magic, Divination Where Did Tarot Cards Come From?...
Answers on questions: Social Studies
- S Social Studies Drag the tiles to the correct boxes to complete the pairs. Match the form of personal narrative with its characteristics. memoir personal essay speech travelogue writing...
- S Social Studies What was one of the key terms of the Treaty of Versailles? Germany could have its military in the Rhineland. All participants could keep their overseas colonies. All participants...
- S Social Studies Which statement best describes the damage done by the Pearl Harbor bombing? Because the attack was expected, few people lost their lives and little damage was done. The...
- S Social Studies Which standard of justice was applied to nazi leaders who were tried at nuremberg after world war ii...
- S Social Studies PLEASE HELP ME ON THIS DO NOT WASTE ANSWERS URGENT WILL MARK BRAINLIEST...
- S Social Studies The following question references the novel The Red Badge of Courage by Stephen Crane. Who fights beside Henry until the end of the battle? a. Jim Conklin c. Simpson b....
- M Mathematics Find e^cos(2+3i) as a complex number expressed in cartesian form....
- M Mathematics Kirchoff s second law says that on a serial circuit that contains only one resistance and an inductor, the sum voltage drops through the inductor and the resistance is equal...
- M Mathematics For a company that manufactures thermostats, the combined cost for labor and material is $5 per thermostat. fixed costs (costs incurred in a given period, regardless of...
- M Mathematics Acold drink is poured out at 52°f. after 2 minutes of sitting in a 72°f room, its temperature has risen to 55°f. find an equation for the drink s temperature at any time...
Ответ:
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 {
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;
}
}
}