Fundamentals of algorithms- module 2) Searching Flashcards
What is searching?
Common task for an algorithm.
What is an example of searching?
1: Phone searches for a signal.
2: Computer searches for an internet link.
What are the 2 main types of search algorithm?
Binary search.
Linear search.
What is a binary search?
Chooses the middle value in a sorted array, then works out whether the value sort is er than the middle value. Then it splits the array again and repeats the check.
What is a linear search (also known as brute-force search)?
In linear search computer searches from 1st item in list to last item in list, 1 by 1, until sought item found.
When should you use a linear search?
When data searched too small, or when data so frequently ammended that sorting the list is a waste of time.