Search Algorithms Flashcards
1
Q
What is a search algorithm (1)
A
1.) An algorithm used to find an item with certain characteristics in a list or collection of items.
2
Q
Linear/Sequential Search (4)
A
- ) Brute force strategy.
- ) Does not require a sorted list.
- ) Moves sequentially through the list until the item is found.
- ) For (lists > 8) Binary search is more efficient.
3
Q
Linear/Sequential | Big O (3)
A
- ) Best: O(1)
- ) Worst: O(n)
- ) Average: O( (n+1)/(k+1) )
4
Q
Binary/Half-interval Search (2)
A
- ) Divide and conquer.
2. ) Requires sorted list.
5
Q
Binary Search | How (3)
A
- ) Compare element with middle element of list.
- ) Discard half which does not contain element
- ) Repeat until found.
6
Q
Binary | Big O (2)
A
- ) Best: O(1)
2. ) Worst/Average: O( log2(n) )