Pergunta

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..

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top