?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Speed of a Linear vs Binary Search on a Large String Array

APCSA-EY61YE

An unsorted String array named dictionary contains a million unique words and you need to determine if a word is found in the array.

Which one of the following statements is true?

A

It is always faster to sort the array, then perform a binary search to find the word.

B

If searching for different words frequently in the array, then it is best to leave the array unsorted and use a linear search to find the word.

C

If only performing a search for a single word, sort the array and use a linear search to find the word.

D

If only performing a search for a single word, sort the array and use a binary search to find the word.

E

If only performing a search for a single word, leave the array unsorted and use a linear search to find the word.