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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly