Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Exercise 03.1 Selection Sort PLEASE USE JAVA USE SELECTION SORT NOT BUBBLE SORT Selection Sort is named because the values in an unordered list,

Lab Exercise 03.1

Selection Sort

PLEASE USE JAVA

USE SELECTION SORT NOT BUBBLE SORT

Selection Sort is named because the values in an unordered list, are selected, one by one, and added to the ordered list. The algorithm described below will probably not be found on any web-site because it is a beginners attempt. But you must use this algorithm to receive credit for this exercise.

This exercise uses three new ideas;

The array as a list of numbers

The random number generator to produce an unordered list

The selection-sort algorithm

The steps to complete this exercise are;

Create and fill an array with a random (unsorted) sequence of numbers between 0 and 1,000,000.

Create a second array, the same size as the first and copy the random (unsorted) numbers into it.

Use a loop to go from sorted[0] to sorted[n-1]

Find the largest element of array named unsorted.

Swap this largest element of unsorted with sorted[i]

increment i by 1

If n > 1 go back to step d

Testing: to test this algorithm,

Fill an array with a sequence of 200 random numbers.

Sort the array in ascending order

Display the values in 4 columns

Sort the same values in descending order

Display the values in 4 columns

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

3. Is there opportunity to improve current circumstances? How so?

Answered: 1 week ago