Package dsa

Class LinearSearch


  • public class LinearSearch
    extends Object
    This library implements linear search.
    • Constructor Detail

      • LinearSearch

        public LinearSearch()
    • Method Detail

      • indexOf

        public static int indexOf​(Object[] a,
                                  Object key)
        Returns the index of key in the array a, or -1.
        Parameters:
        a - array of objects.
        key - search key.
        Returns:
        the index of key in the array a, or -1.
      • indexOf

        public static int indexOf​(int[] a,
                                  int key)
        Returns the index of key in the array a, or -1.
        Parameters:
        a - array of objects.
        key - search key.
        Returns:
        the index of key in the array a, or -1.
      • indexOf

        public static int indexOf​(double[] a,
                                  double key)
        Returns the index of key in the array a, or -1.
        Parameters:
        a - array of objects.
        key - search key.
        Returns:
        the index of key in the array a, or -1.
      • main

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