Fastest String Search Algorithm.

Amit Choudhary amitchoudhary0523@gmail.com
Wed Jun 9 12:18:17 GMT 2021


On Wed, Jun 9, 2021, 5:35 PM Phil Blundell <pb@pbcl.net> wrote:

>
> Do you have any representative real-world testcases or statistics that you
> can share with us?


I had shared my program earlier which has around 60 KB of text copied from
Internet.

  For example, what is the reason for believing that the
> needle "should" be in the middle?
>

strstr() does a 2 way search - from the beginning of the haystack and from
the end of haystack.

So, if needle is located at the beginning or end of haystack, then strstr()
will outperform many algorithms.

The real test for strstr() would be if needle is located in the middle of
the haystack.

Regards,
Amit


More information about the Libc-alpha mailing list