Published online by Cambridge University Press: 14 July 2016
Strings are generated by sequences of independent draws from a given alphabet. For a given pattern H of length l and an integer n ≥ l, our goal is to maximize the probability of stopping on the last appearance of the pattern H in a string of length n (if any), given that, if we choose to stop on an occurrence of H, we must do so right away. This contrasts with the goals of several other investigations on patterns in strings such as computing the expected occurrence time and the probability of finding exactly r patterns in a string of fixed length. Several motivations are given for our problem ranging from relatively simple best choice problems to more difficult stopping problems allowing for a variety of interesting applications. We solve this problem completely in the homogeneous case for uncorrelated patterns. However, several of these results extend immediately to the inhomogeneous case. In the homogeneous case, optimal success probabilities are shown to vary, depending on characteristics of the pattern, essentially between the value 1/e and a new asymptotic constant 0.619…. These results demonstrate a considerable difference between the true optimal success probability compared with what a first approximation by heuristic arguments would yield. It is interesting to see that the so-called odds algorithm which gives the optimal rule for l = 1 yields an excellent approximation of the optimal rule for any l. This is important for applications because the odds algorithm is very convenient. We finally give a detailed asymptotic analysis for the homogeneous case.