Free Version
Moderate

# Search Algorithms Two

APCSP-4EG4XI

Consider the following algorithms. Assume that you have a deck of cards with numbers on them and you are looking for a card with a particular number:

Algorithm 1:

1. look at the middle card in your deck.
2. if correct, done! You have found what you are searching for!
3. if you are looking for a larger number,discard the lower half of the deck
4. else, discard the upper half of the deck

Algorithm 2:

1. look at the first card in your deck.
2. if this is what you are looking for, great! You found what are searching for!

Which of the following statements is TRUE?

A

Algorithm 1 is an example of linear search. It will work for any list.
Algorithm 2 is an example of binary search. For it to work, the list must already be sorted.

B

Algorithm 1 is an example of linear search. For it to work, the list must already be sorted.
Algorithm 2 is an example of binary search. It will work for any list.

C

Algorithm 1 is an example of binary search. It will work for any list.
Algorithm 2 is an example of linear search. For it to work, the list must already be sorted.

D

Algorithm 1 is an example of binary search. For it to work, the list must already be sorted.
Algorithm 2 is an example of linear search. It will work for any list.