What is the minimum number of comparisons under best case scenario for KMP algorithm ?
What is the minimum number of comparisons under best case scenario for KMP algorithm
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, the minimum number of comparisons in best case would be the length of your string, meaning you found a match first try. The algorithm is O(n), meaning that the upper bound or worst case scenario would take n comparisons where n is the length of the string that you are searching. The wiki is pretty good.
http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm