Package dsa

Class Insertion


  • public class Insertion
    extends Object
    This library implements insertion sort.
    • Constructor Detail

      • Insertion

        public Insertion()
    • Method Detail

      • sort

        public static void sort​(Comparable[] a)
        Sorts the array a according to the natural order of its objects.
        Parameters:
        a - the array to sort.
      • sort

        public static void sort​(Object[] a,
                                Comparator c)
        Sorts the array a according to the order induced by the comparator a.
        Parameters:
        a - the array to sort.
        c - the comparator to determine the order of the array.
      • sort

        public static void sort​(int[] a)
        Sorts the array a.
        Parameters:
        a - the array to sort.
      • sort

        public static void sort​(double[] a)
        Sorts the array a.
        Parameters:
        a - the array to sort.
      • main

        public static void main​(String[] args)
        Unit tests the library.
        Parameters:
        args - the command-line arguments.