For the two string searching algorithms: KMP and suffix tree, which is preferred in which cases? Give some practical examples.
For the two string searching algorithms: KMP and suffix tree, which is preferred in
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.
A suffix tree is better if you will have to answer a lot of queries such as “is the needle present in the haystack?”. KMP is better if you only have to search for one string in another single string, and not have to do it a lot of times.
A suffix tree is a much more general data structure, so you can do a lot more with it. See what you can do with it here. KMP is useful for finding if a string is a substring in another string.
You might also want to check out other algorithms, such as Boyer-Moore, Rabin-Karp and even the naive algorithm, as there are situations (inputs) in which one is better than the others.
Bottom line is: