There is an algorithm O (m. | Σ |), and since the transaction function has a possible input O (m. | Σ |), there is no better algorithm because of the time complexity.
, π, d (q, x). d (q, x) , , q, - x. P [q], q + 1, q + 1. d (q, p [i]) = q + 1. . π [q] q, P [0.. π [q]] P [0.. q]. π [q] q, p [i], .
, !