Question: Must use code provided for bubble sort and selection sorts but can be modified. public void selectionSort() { int loc, minIndex; for(loc = 0; loc

Must use code provided for bubble sort and selection sorts but can be modified.

public void selectionSort()

{

int loc, minIndex;

for(loc = 0; loc < length; loc++)

{

minIndex = minLocation(loc, length - 1);

swap(loc, minIndex);

}

}//end selectionSort

private void swap(int first, int second)

{

DataElement temp;

temp = list[first];

list[first] = list[second];

list[second] = temp;

}//end swap

private int minLocation(int first, int last)

{

int loc, minIndex;

minIndex = first;

for(loc = first + 1; loc <= last; loc++)

if(list[loc].compareTo(list[minIndex]) < 0)

minIndex = loc;

return minIndex;

}//end minLocation

public static void bubble_srt( int a[], int n ){

int i, j,t=0;

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

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

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

t = a[j-1];

a[j-1]=a[j];

a[j]=t;

}

}

}

Create a new class named SearchSort. Your new class should do the following:

Instantiate a new array named myFavoriteMovies with 6 type String components

call method inputArray to fill the array with your favorite movies

call a method to print the contents of your list

use a sequential search to find a movie that you know is NOT in your list

use a sequential search to find a movie that you know IS in your list

use a bubble sort to sort your list in ascending order

call a method to print the contents of your list

Instantiate a new array named myFavoriteMusic with 5 type String components

call method inputArray to fill the array with your favorite music groups

call a method to print the contents of your list

use an selection sort to sort your list in descending order

call a method to print the contents of your list

use a binary search to find a group that you know is NOT in your list

use a binary search to find a group that you know IS in your list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!