# The number of comparisons in brute force string search

In the brute force approach to string search, how many character comparisons will the algorithm make when searching for "lido" in the string "supercalifragilisticexpialidocious"?

• I would say 33... – Nicolas FRANCOIS Mar 25 '17 at 10:31
• How did you calculate the result? – Hamideh Mar 25 '17 at 10:35
• First put "lido" under the "s" : one comparison, shift right. "lido" under "u", one comparison, shift right... When "lido" gets under "lifragili", 3 comparisons, $f\ne d$, shift right... Until "lido" under "lidocious", four comparisons, we have a winner... – Nicolas FRANCOIS Mar 26 '17 at 22:33
• 7+3(lif)+5+3(lis)+9+4(lido)+2=33 In this case, the algorithm jumps over "if" in "lif" , "is" in "lis" and "ido" in "lido". Am I right? – Hamideh Mar 28 '17 at 1:04