Are there multiple KMP algorithmic approaches with different space complexities? What is the difference?
问题 I am reading about the KMP substring search algorithm and the examples I find online use an one-dimensional table to build the prefix information table. I also read the Sedgewick explanation and he used a 2-D array to build the table and explicitly states that the space complexity of KMP is O(RM) where R is the alphabet size and M the pattern size while everywhere else it is stated that the space complexity is just O(M + N) i.e. the text to process and the pattern size itself. So I am