Untitled
unknown
plain_text
a year ago
850 B
6
Indexable
Never
## Program to undertake a binary search names = ["Alfi", "Amara", "Amisha", "Carla", "Criselle", "Jemima", "Jemimah", "Kemi", "Maria", "Mia", "Mona-Lisa", "Nayana", "Ollie", "Ore", "Racheal", "Tiffany"] searchItem = # Find the midpoint ## If there are 5 thi ngs in the list, the midpoint is the 3rd item. ## If there are 6 things in the list, the midpoint is the 4th item (choosing to always go up) ## Medians can be found using the formula (n + 1)/2 ## The 'ceil' function in math will be useful here - import math ## How will we reference the position in the array we need? midpoint = # Check the midpoint value against the search item - does it match? # Otherwise discard half of the list # repeat ## We don't know how many times this will happen ## Use a flag to symbolise whether the item has been found or not.