Searching ________ The purpose of the linear search algorithm is to find a target item within a list.
2
New cards
Example
Binary search in operation to find 81
3
New cards
what is the purpose of linear search algorithms?
The purpose of the linear search algorithm is to find a target item within a list.
4
New cards
Summarise the method of a linear search algorithm
The linear search algorithm compares each list item one-by-one against the target until the match has been found and returns the position of the item in the list.
5
New cards
Summarise the method of a binary search algorithm
The binary search algorithm works on a sorted list by identifying the middle value in the list and comparing it with the search item.
6
New cards
What are the advantages of a linear search?
• Very simple algorithm and easy to implement • No sorting required • Good for short lists
7
New cards
What are the disadvantages of a linear search?
• slow because it searchers through the whole list • very inefficient for long lists
8
New cards
What is the advantage of a binary search?
a binary search is much quicker than linear search, because it halves the search zone each step