Question
Please solve it using Eclipse JAVA-SE13 Urgent!!!! Sorting: import java.util.Random; public class Sorting { public static void main(String[] args) { // TODO Auto-generated method stub
Please solve it using Eclipse JAVA-SE13
Urgent!!!!
Sorting:
import java.util.Random;
public class Sorting {
public static void main(String[] args) { // TODO Auto-generated method stub int n=1000; int x[]= new int [n]; Random r = new Random(); for(int i=0;i
public static void selectionSort(int[] a) { int outer, inner, min; for (outer = 0; outer a[min]) min = inner; int temp = a[outer]; a[outer] = a[min]; a[min] = temp;
} } public static void insertionSort(int[] a) { int inner,outer; for (outer =1; outer
} } }
Sorting String: public class SortingString {
public static void main(String[] args) { // TODO Auto-generated method stub
} public static void bubbleSort(String[] a) { int outer, inner; int counterswap=0; for (outer = a.length - 1; outer > 0; outer--) { // counting down boolean sorted=true; for (inner = 0; inner 0) { // if out of order... String temp = a[inner]; // ...then swap a[inner] = a[inner + 1]; a[inner + 1] = temp; sorted=false; counterswap++; } } if(sorted) return; } System.out.println("BubbleSort Swap"+counterswap); } }
1. With reference to lab 6, assume you have class Student that has id (int), name(String), gpa(double), update the sorting algorithms covered to receive an array of students, and sort them based on the gpa. Test the 3 sorting algorithms in the mainStep 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