@@ -0,0 +1,2421 @@
+package module6;%0A%0Aimport demos.Airport;%0A%0Apublic class LinearSearchExample %7B%0A%0A  public static String findAirportCodeMyVersion(String toFind, Airport%5B%5D airports) %7B%0A    String found = %22No match%22;%0A%0A    for (Airport airport : airports) %7B%0A      final int airportID = airport.getAirportID();%0A      final String airportIDString = String.valueOf(airportID);%0A      if (airportIDString.equals(toFind)) %7B%0A        found = airportIDString;%0A        break;%0A      %7D%0A    %7D%0A%0A    return found;%0A  %7D%0A%0A  public static String findAirportCode(String toFind, Airport%5B%5D airports) %7B%0A    int index = 0;%0A    while (index %3C airports.length) %7B%0A      Airport airport = airports%5Bindex%5D;%0A      if (toFind.equals(airport.getCity())) %7B%0A        return airport.getCode3();%0A      %7D%0A      index++;%0A    %7D%0A    return %22Not found%22;%0A  %7D%0A%0A%0A  /**%0A   * Binary search pseudo code:%0A   * initialize low = 0, high = size of list (length of array -1)%0A   * while ???:%0A   * mid = (high+low)/2%0A   * if the city to find equals the city at mid,%0A   * return the airport code%0A   * if the city is less than the city at mid%0A   * high = mid - 1%0A   * else low = mid + 1%0A   * %3Cp/%3E%0A   * return a value to indicate not found%0A   */%0A  // to find a city name%0A  public static String findAirportCodeBS(String toFind, Airport%5B%5D airports) %7B%0A    int low = 0;%0A    int high = airports.length;%0A    int mid;%0A    while (low %3C= high) %7B%0A      mid = ((high - low) / 2);%0A      int compare = toFind.compareTo(airports%5Bmid%5D.getCity());%0A      if (compare %3C 0) %7B%0A        high = mid - 1;%0A      %7D else if (compare %3E 0) %7B%0A        low = mid + 1;%0A      %7D else %7B%0A        return airports%5Bmid%5D.getCode3();%0A      %7D%0A    %7D%0A    return null;%0A  %7D%0A%0A  // selection sort%0A  public static void selectionSort(int%5B%5D values) %7B%0A    int indexMin;%0A    for (int i = 0; i %3C values.length - 1; i++) %7B%0A      indexMin = i;%0A      for (int j = i + 1; j %3C values.length; j++) %7B%0A        if (values%5Bj%5D %3C values%5BindexMin%5D) %7B%0A          indexMin = j;%0A        %7D%0A      %7D%0A      swap(values, indexMin, i);%0A%0A    %7D%0A  %7D%0A%0A  // merge sort%0A  public static void mergeSort(int%5B%5D values) %7B%0A    int currentIndex;%0A    for (int pos = 1; pos %3C values.length; pos++) %7B%0A      currentIndex = pos;%0A      while (currentIndex %3E 0 && values%5BcurrentIndex%5D %3C values%5BcurrentIndex - 1%5D) %7B%0A        swap(values, currentIndex, currentIndex - 1);%0A        currentIndex = currentIndex - 1;%0A      %7D%0A%0A    %7D%0A  %7D%0A%0A  private static void swap(int%5B%5D values, int indexMin, int i) %7B%0A%0A  %7D%0A%0A%7D%0A

add linear search example