After reading this, you will basically count the next array of kmp algorithm.

After reading this, you will basically count the next array of kmp algorithm.

The next array solution of the kmp algorithm may be encountered during the postgraduate entrance examination of computer science and the data structure examination of the university. After encountering it, many students may go around their heads and scratch their hair, but find that they still can’t do it.
If you can't do it, then let's take a look at the specific method (in the picture below) (warm reminder: if you don't know the concept of prefix and suffix, you can look through the textbook of data structure, or in the CSDN blog Look up and find relevant information. This is for students who have learned the kmp algorithm, but you are not likely to ask for the number of students who are subscripts in the next array. Of course, if you have a better way, you can also leave a message in the message area).
Believe that you read the following analysis, you will definitely scream, it turns out that the next array is so simple! ! !
OK, don’t talk nonsense, go directly to the analysis chart:
Insert picture description here
OK, I believe you will be able to see this analysis process! ! !
Thank you for reading. Due to the limited level of the author, mistakes are inevitable. If readers find mistakes, please criticize them and leave a message in the message area. I will definitely modify them as soon as possible. Thank you.

Guess you like

Origin blog.csdn.net/m0_46833224/article/details/114094031