6

Can anyone point to best algorithm for substring search in another string? or search for a char array in another char array?

0

4 Answers 4

8

The best from what point of view? Knuth-Morris-Pratt is a good one. You can find more of them discussed on the Wikipedia entry for string searching algorithms.

Sign up to request clarification or add additional context in comments.

Comments

3

It depends on what types of searching you are doing. Specific substring over a specific string? Specific substring over many different strings? Many different substrings over a specific string?

Here's a popular algorithm for a specific substring over many different strings.

Comments

1

Boyer-Moore algorithm: http://en.wikipedia.org/wiki/Boyer–Moore_string_search_algorithm

Comments

0

This strstr() implementation seems pretty slick.

1 Comment

It is strstr.c for alpha. Which algorithm it uses? Which algorithm is used in x86 (or _64) for strstr?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.