Question: The program is mostly using the myArrayLIst and the code is a below the directions. 1.Implement the MySort class with the following operations. a.bubbleSort(MyArrayList arraylist)

The program is mostly using the myArrayLIst and the code is a below the directions.

1.Implement the MySort class with the following operations. a.bubbleSort(MyArrayList arraylist) conduct bubble sort on the elements contained in a MyArrayList object. b.selectionSort(MyArrayList arraylist) conduct selection sort on the elements contained in a MyArrayList object.

2.Implement the MySearch class with the following operations. a.binarySearch(MyArrayList arraylist, Comparable target) conduct binary search on sorted elements contained in a MyArrayList object. b.linearSearchSorted (MyArrayList arraylist, Comparable target) conduct linear search on sorted elements contained in a MyArrayList object.

3.Both the MySearch and MySort classes should be created in the collection package.

4.After implementing the MySearch and MySort classes you will test them. To test the MySearch and MySort classes you will create a Lab3 class under the lab package.

5.In the Lab3 class you will create an static void test() method. In this test method you will do the following:

a.Create a numArraylist of MyArrayList type.

b.Generate a sequence of 800 integer numbers in the range [100, 999] using java.util.Random with current system time as the random seed (use java.lang.System.nanoTime()). Insert this sequence of numbers into numArraylistone by one when it is being generated.

c.Sort numArraylist using bubbleSort.

d.Print out numArraylist onto the screen.

e.Prompt user to type in a number through keyboard.

f.Search that number using linearSearchSorted, and print out the returned value onto screen.

g.Call numArraylist.removeRange(50, 650).

h.Then call numArraylist.reverse().

i.Sort numArraylist using selectionSort.

j.Print out numArraylist onto the screen.

k.Prompt user to type in a number through keyboard.

l.Search that number using binary. Search, and print out the returned value onto screen.

The code for the myArrayList

package collection;

/* * @This program clones an array * @author jgemerick0 * @version 2020.20.2 */

public class MyArrayList implements Cloneable{ public Object[] obj; public int maxsize = 100,initialsize = 0; public MyArrayList(){ obj = new Object[maxsize]; } public void append(Object element){ if(initialsize < maxsize) obj[initialsize++] = element; else System.out.println("Full"); } public void clear(){ obj = new Object[maxsize]; } public void contains(Object element){ int flag = 1; for(int i=0;iindex;i--){ obj[i] = obj[i-1]; } obj[index] = element; } public boolean isEmpty(){ if(initialsize == 0) return true; return false; } public void removedAt(int index){ for(int i=index;i= minCapacity) return true; return false; } public Object clone() throws CloneNotSupportedException{ return super.clone(); } public void removeRange(int fromIndex,int toIndex){ for(int i=fromIndex;i

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!