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