Question: * * * * * I just need MySorts.java and Main.java java code * * * * * * IList . java * public interface
I just need MySorts.java and Main.java java code
IListjava
public interface IList
Adds an element at the end of the list.
public void addT item;
Stores a new item at a specified index
Throws NoSuchElementException if index is out of bounds.
public void setint index, T item;
Inserts an element at the specified index
Throws NoSuchElementException if index is out of bounds.
public void insertint index, T item;
Removes the element at the specified index
Throws NoSuchElementException if index is out of bounds.
public void removeint index;
Returns the element at the specified index
Throws NoSuchElementException if index is out of bounds.
public T getint index;
Returns the size of the list.
@return the number of elements in the list
public int size;
MyArrayListjava
import java.util.ArrayList;
public class MyArrayList implements IList
private ArrayList list new ArrayList;
@Override
public void addT item
list.additem;
@Override
public int size
return list.size;
@Override
public T getint index
return list.getindex;
@Override
public void setint index, T item
list.setindex item;
@Override
public void insertint index, T item
list.addindex item;
@Override
public void removeint index
list.removeindex;
Additional Information
MySorts quicksort algorithm
the quicksort method will take a reference to an IList object as its only argument. This method will call the quicksortHelper method to do the actual work of sorting the list. This is the method that one would call to apply the quicksort algorithm to a list of values. By the time this method returns, the values in the argument IList should be sorted.
the quicksortHelper method is a recursive method that will implement the actual quicksort algorithm. The first argument is a reference to the list of values that is to be sorted. The second and third int arguments are the index values representing the current partition of the list to be sorted. For example, given an IList named list of values, quicksortHelperlist would quicksort the partition of the list staring at index and ending at index
the partition method will take as its first argument, a reference to the list of values that is to be partitioned. The second and third int arguments are the index values representing the current section of the list to be partitioned.
For example, given an IList named list of values, partitionlist would partition the section of the list staring at index and ending at index This method must return the index at which the pivot value was finally placed at the end of this partition operation.
For this assignment, you should always use the last int argument value as the initial pivot index for the partition operation. For example, given an IList named list of values, partitionlist would use the high index value as the index of the pivot value for this partition operation.
the swap method will take as its first argument, a reference to an IList object. The second and third int arguments are the indexes of the two items in the list to have their locations swapped. For example, given an IList named list of these values swaplist would swap the values currently stored at indexes and and the list would now look like this
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
