Home > database >  About the next value with nextval KMP
About the next value with nextval KMP

Time:09-27

As a dish of chicken, I began to look at this problem, a word, the word is difficult, difficult three words in the difficult, four word male and male, hey hey ﹃ o (o)
Began to dry area, after watching the countless big sums up methods themselves, specific links don't put the above, there are too many after all,

The next value
Next array method is: first the next value is 0, the second of the next value is 1, solving each of the next value behind, according to the former one, the first will be a corresponding to its next value before the content, if equal, then the position of the next value is before a next plus 1; If, forward looking for the next value corresponding to the content of the comparing with the former one, until I find a bit on the next value corresponding to the content of the content and the former one is equal, is this a corresponding value plus 1 is the demand of next value; If found first before and didn't find a equal, then the demand of the next on the bit value is 1,





Nextval values is under the condition of known the next to solve, I think the simplest and best,
Pattern string abaabcac next 01122312 nextval values 01021302
1. The first nextval values must be 0, the second if the first is same to 0, if different to 1,
2. The third next value is 1, so will the third and the first comparison, are a, the same, then, the third nextval value is 0,
3. The fourth next value is 2, then we compare the fourth and the second, and different, the fourth nextval values for its next, to 2,
4. The fifth next value is 2, then we compare the fifth and the second, and the same, the second of the next value is 1, then continue to the second, compared with the first, the fifth nextval values for the second next, is 1,
5. The next sixth value of 3, then the sixth and the third, different, the sixth nextval values for its next, 3,
6. 7 of the next value is 1, then the seventh and the first comparison, the same, is the seventh nextval value is 0,
The next value of 7. 8 to 2, then compared the eighth, and second, the different, is the eighth nextval values for its next, to 2,
  • Related