I’m looking through large arrays for particular sequences and I feel like I’m approaching the problem using brute force rather than computer science.
Currently I’m looking sequentially down the large array for the first item in the search sequence, then checking each item after that until a failure or a complete match. This provides 100% accuracy but it’s not very fast with large arrays.
I was never a computer science student so I missed out on many algorithm classes that plenty of people around here probably had. Is there a better way to search for sequences in arrays? I’m not necessarily interested in perfect accuracy if it makes a difference.
How about using the Boyer-Moore algorithm? It’s fairly simple and straightforward, and can increase the practical speed quite a lot, especially if your target sequence is fairly long. It’s meant for searching for strings, but that’s just a particular type of array of course.