What should a linear search return if the item is found?
• The index of the target
What should a linear search return if the item is not found?
• -1
• Or another clear ‘not found’ output
What important index rule should you remember in search questions?
• Lists and arrays are usually 0-indexed
In a linear search, when should the algorithm stop?
• As soon as the item is found
• Or when the end of the list is reached
Which search is better for a small or unsorted list?
• Linear search
Which search is better for a large sorted list?
• Binary search
What should you do in a binary search on an even-length list?
• Choose middle-left or middle-right
• Then stay consistent
What happens in binary search if the target is smaller than the middle value?
• Search the left half
What happens in binary search if the target is greater than the middle value?
• Search the right half
When does binary search stop?
• When the target is found
• Or when the search range cannot be split further