14. Binary Search

Binary search to find an item or an insertion point.
  1. Binary search: the traditional function returning an index where the wanted item is found, or -1 if the item is not found.

     public static int binarySearch(ArrayList<String> data,
                                    String wanted);
    
  2. Binary insert: this function finds the index (idx) at which a new item fits in the ordering, so that data.add(idx, newItem) results in data still being sorted.

     public static int binaryInsert(ArrayList<String> data,
                                    String newItem);
    
Last modified August 18, 2023: 2022-2023 End State (7352e87)