question 1
Brute force looks for ec in nneee. How many comparisons does it make?
the answer, and why
the answer is A
At each of the 4 places, it compares from the left until a letter differs or the whole pattern matches: 1 + 1 + 2 + 2. That is 6.
if you chose another
- That counts only the letters that matched, 0 + 0 + 1 + 1, not the ones that differed.
- That is the whole pattern at every place, 4 times 2.
- That counts the places, not the comparisons.