Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help doing this java program. This is the MyArrayList code, and below is everything needed to run it. /* * To change

I need some help doing this java program.

image text in transcribed

This is the MyArrayList code, and below is everything needed to run it.

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package collection;

/* * @This program clones an array * * */

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 index;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

Lab 2 Program

package lab;

import collection.MyArrayList;

/* * @This program clones an array * @author jgemerick0 * @version 2020.20.2 */ public class Lab2{ public static void test(String[] cmd) throws CloneNotSupportedException { MyArrayList list = new MyArrayList(); list.append(0); list.append(2); int one = 0,two =1; for(int i=0;i

}.

This the main to class.

package main;

import lab.Lab2;

/** * @This program prints a clone of another array * @author jgemerick0 * * @version 2020.20.2 */ public class Main { public static void main(String[] args) throws CloneNotSupportedException { Lab2.test(args); } }

1. Implement the MySort class with the following operations. a bubbleSort( M ArrayList arraylist) - conduct bubble sort on the elements contained in a My ArrayList 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. binary Search (MyArrayList arraylist, Comparable target) - conduct binary search on sorted elements contained in a MyArrayList object. b. linear SearchSorted (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 My Search 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 numArraplist 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 num4rraylist one 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 linear SearchSorted, and print out the returned value onto screen. g. Call numArraylist.removeRange(50, 650). h. Then call mumArraylist.reverse(). i. Sort numArraylist using selectionSort. j. Print out numArraylist onto the screen k. Prompt user to type in a number through keyboard. 1. Search that number using binary Search, and print out the returned value onto screen. 6. Under the main package, in the Main class. remove or comment it out) the contents of the main method we have added in the last lab (or project) and do the following: Lab3.test()

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

More Books

Students also viewed these Databases questions