Question: Section 3.3 1- Add the following method to the Insertion Sort Program given in Section 3.3: Add a method called noDups() that removes duplicates from
Section 3.3


1- Add the following method to the Insertion Sort Program given in Section 3.3:
Add a method called noDups() that removes duplicates from a previously sorted array without disrupting the order. Use the insertionSort() method to sort the data. Recall that after removing the duplicates, the resulting array cannot have any holes, i.e., be sure to shift the elements such that all elements in the array are in contiguous locations.
Add appropriate code to the main() method to exercise the noDups() method.
Sample I/O:
4 5 public class ArrayIns { private long[] a; private int nElems; // ref to array a // number of data items public ArrayIns (int max) // constructor a = new long(max]; nElems = 0; // create the array public void insert (long value) // put element into array a[nElems] = value; nElems++; = = = = = = = = public void display() // displays array contents HHHHHHNNNNNNNNNNMMMM for(int j=0; j
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
