Background: Data about herpesvirus microRNA motifs on human circular RNAs suggested the following statistical question. Consider independent random counts, not necessarily identically distributed. Conditioned on the sum, decide whether one of the counts is unusually large. Exact computation of the p-value leads to a specific algorithmic problem. Given n elements g0,g1,...gn-1 in a set with the closure and associative properties and a commutative product without inverses, compute the jackknife (leave-one-out) products gbar;=g0,g1,...gj-1 g j+1...gn-1 (0≤j<n).
Results: This article gives a linear-time Jackknife Product algorithm. Its upward phase constructs a standard segment tree for computing segment products like g[i,j)=gigi+1...gj-1; its novel downward phase mirrors the upward phase while exploiting the symmetry of and its complement gbar;j. The algorithm requires storage for elements of and only about products. In contrast, the standard segment tree algorithms require about n products for construction and log2 n products for calculating each gbar;j, i.e., about products n log n in total; and a naïve quadratic algorithm using n-2 element-by-element products to compute each gbar;j requires n (n-2) products.
Conclusions: In the herpesvirus application, the Jackknife Product algorithm required 15 minutes; standard segment tree algorithms would have taken an estimated 3 hours; and the quadratic algorithm, an estimated 1 month. The Jackknife Product algorithm has many possible uses in bioinformatics and statistics.