What are good test cases for benchmarking & stress testing substring search algorithms?
问题 I'm trying to evaluate different substring search (ala strstr) algorithms and implementations and looking for some well-crafted needle and haystack strings that will catch worst-case performance and possible corner-case bugs. I suppose I could work them out myself but I figure someone has to have a good collection of test cases sitting around somewhere... 回答1: Some thoughts and a partial answer to myself: Worst case for brute force algorithm: a^(n+1) b in (a^n b)^m e.g. aaab in