Question

Can someone please help me understanding which one is more efficient strstr() or KMP as recently I was doing a question on SPOJ and found that strstr() was in one way or other faster than KMP.. someone please explain the mystery behind this..

Was it helpful?

Solution

You are comparing apples with pears, strstr() is a function to find substrings, KMP is an algorithm to do it, so strstr() could theoretically be implemented using KMP. You need to find out which algorithm is the strstr() in question implementing to give a statement.

Take a look at this answer and the comments on it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top