Searching Algorithm Flashcards
1
Q
What is Linear Search?
A
Process of looping through the list iteratively, one by one and checking if the specified value exists.
2
Q
What is Binary Search?
A
Algorithm for searching a sorted array. It works by repeatedly dividing the search space in half until the target element is found.
3
Q
Give an example of binary search
A
Picking a middle spot/number in the list (search key), if the number where the search key is higher/bigger than the target element. Then cut the algorithm in half by removing the right/upper side, narrowing the search interval. Otherwise, narrow the search by cutting the left side, this is then done repeatedly until the value is found or the interval is empty.