Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started