Package Aa;class insertsort{private long[] a;private int nelems;//construction method public insertsort (int max) {a = new Long[max];nelems = 0;} Insert method public void Insert (Long value) {A[nelems] = Value;nelems + +;} Display method public void display () {for (int j = 0; J < Nelems; J + +) {System.out.println (A[j] + "");} System.out.println ("");} Sort method Public long[] Insertionsort () {int out,in;for (out = 1, out < Nelems; out++) {Long temp = A[out];in = Out;while (In & Gt 0 && a[in-1] >= temp) {A[in] = a[in-1];in--;} A[in] = temp;} return A;} Go to Heavy method public void Nodups (long[] arr) {for (int i = 1; i < nElems-1; i++)//Iterate over array elements, starting with the second entry {for (int j = 0; J < i; j + +)/ /number of times per round of comparison {if (a[j] = = A[i])//If traversing an item and before an item equals {int k = i;//The index of the traversed item is fetched while (K+1 < Nelems) {//traversing the element item after traversing the item a[k] = a[k+1];//will traverse the After the element item moves forward one k++;} Nelems--;//array length minus one i--;//because traversing an item before an item moves forward to the Traverse item, if I do not subtract a less than one item}}}}}public class Insertsortapp {public static void main (string[] args) {int maxSize = 100;insertsort arr = new Insertsort (maxSize); Arr.insert (); arr.insert; Arr.insert ((Arr.insert); Arr.insert (77); Arr.insert (n); Arr.insert (one); Arr.insert (xx); Arr.insert (); Arr.display (); long[] Sortarr = Arr.insertionsort (); Arr.display (); arr.nodups (Sortarr); Arr.display ();}}
Java does not use any of the existing methods to completely self-write the de-heavy method