The next array is solved by:
The next value for the first digit is 0, and the second next value is 1, followed by the next value for each bit, compared to the previous one. First, compare the previous digit with its next value, and if it is equal, the next value of the bit is the next value of the previous digit plus 1, and if not, go ahead and look for the next value to compare it to the previous one. Until the next value of the content on a bit is found to be equal to the previous digit, the corresponding value of this bit plus 1 is the next value of the requirement, and if the first digit is found without finding the same content as the previous one, then the next value on the demand bit is 1.
This paragraph began to read several times did not thoroughly understand, read several posts, and finally figure out how the next array of specific solutions. Or an example to illustrate the specific solution process
Let's say the next array pattern string for string ′ababaaababaa′ a B A B a A a b a a a B a a subscript 1 2 3 4 5 6 7 8 9 10 11 12
1, the first two digits: Next array The first two digits must be 0,1 that is, the first two-digit AB corresponding next array is 01, then: pattern string A B A B a a B a B a a subscript 1 2 3 4 5 6 7 8 next array 9 0
2, next look at the third, according to the next array solution method. The next value for the second digit of the third b,b is 1 corresponding to the a,b and a, and continues to look for the corresponding content of the next value to compare with the previous one. Because finding the first bit does not find the same content as the previous one, the next value of the third digit A is 1, then: The pattern string a B A B a A a a B a B a a subscript 1 2 3 4 5 6 7 8 9 One next array 0 1 1
3, next to look at the fourth-bit b,b the next value of a of 1 corresponding to the content of a, is the same, so the next value of this bit B is the next value of the previous a plus 1, which is the 2 mode string a B A B a A a a B a B a subscript 1 2 3 4 5 6 7 8 9 10 11 12 Next array 0 1 1 2
4, next look at the fifth bit of a,a the next value of B 2 corresponding to the content of B, equal, so the next value of the bit A is the next value of the previous B plus 1, that is, the 3 mode string a B A B a A a B a B a a subscript 1 2 3 4 5 6 7 8 9 10 11 12 Next array 0 1 1 2 3
5, next to look at the sixth-bit a,a the next value of a of 3 corresponding to the content of a, equal, so the next value of the bit A is the next value of the previous a plus 1, that is, the 4 mode string a B A B a A a B a B a a subscript 1 2 3 4 5 6 7 8 9 10 11 12 Next array 0 1 1 2 3 4
6, next to look at the seventh-bit a,a the next value of a of 4 corresponding to the content of B, not equal, go ahead and look for what the next value corresponds to compare to the previous one, B's next value 2 corresponding to the content of B, still not equal, continue to look forward, second B's next value 1 corresponding to the content of a, equal. Because the equality is achieved at the second place B, so the next value of the seventh digit A is added 1 on the next value of the second digit B, that is, the 2 pattern string a B A B a A a b A, a a B a a subscript 1 2 3 4 5 6 7 8 9 Next array 0 1 1 2 3 4 2
7, the next look at the eighth position, the same reason, to get B next value is 2 mode string a B A B a A, a B A, a b. A B a subscript 1 2 3 4 5 6 7 8 9 One next array 0 1 1 2 3 4 2 2
8, next look at the Nineth place, the next value of the previous B, 2 corresponds to B, equal, so here next is the 3 pattern string a B A B a a B a a b. A B a a subscript 1 2 3 4 5 6 7 8 9 Next array 0 1 1 2 3 4 2 2 3
9, the tenth place is equally available, the 4 mode string a B A B a A a b a a b a a subscript 1 2 3 4 5 6 7 8 9 One next array 0 1 1 2 3 4
10, the next value of the first B of the 11th digit A, 4 corresponds to the content B, equal, so here next value is 5 mode string a B A B a A a B a B a A and a a a a B. the Subscript 1 2 3 4 5 6 7 8 9 Next array 0 1 1 2 3 4 2 3 4 5
11, finally, the 12th bit of the same can get the next value bit 6 mode string A B A B a A a b a a B a a a a B. Subscript 1 2 3 4 5 6 7 8 9 One next array 0 1 1 2 3 4 2 2 3 4
In summary, the next array of string ′ababaaababaa′ is 011234223456