سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top