How many character comparisons will be made by the bruteforc
How many character comparisons will be made by the brute-force algorithm on page 105 of the textbook in searching for the pattern SUCCESS in the following text, which contains 100 characters including letters, spaces and punctuation marks? Show your calculation to receive credit. An answer without calculation, even though correct, will not receive credit.
Solution
Given a pattern Q characters in length
and a text N characters
then in best case
For example, Q=6.
AAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAA
6 comparison made
Total number of comparisons: is Q
in worst case
AAAAAAAAAAAAAAAAAAAAAAAAAAAH
o is the pattern
then o is comapre with first A.then second
then third upto length of string ie N
