Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 0; outer--) { // counting down boolean sorted=true; for (inner = 0; inner a[inner + 1]) { // if out of order... int 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); }<>

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 0 && a[inner - 1] >= temp) { a[inner] = a[inner - 1]; inner--; } a[inner] = temp;

} } }

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 main

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_2

Step: 3

blur-text-image_3

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

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions

Question

What did they do? What did they say?

Answered: 1 week ago