Betweenness is an algorithmic problem in order theory about ordering a collection of items subject to constraints that some items must be placed between others. It has applications in bioinformatics and was shown to be NP-complete by . However, it can easily be solved when all unordered triples of items are represented by an ordered triple of the input, by choosing one of the two items that are not between any others to be the start of the ordering and then using the triples involving this item to compare the relative positions of each pair of remaining items.

The related problem of finding an ordering that maximizes the number of satisfied triples is MAXSNP-hard, implying that it is impossible to achieve an approximation ratio arbitrarily close to 1 in polynomial time unless P = NP.

The minimum version of the problem restricted to the tournaments was proven to have polynomial time approximation schemes (PTAS). One can achieve an approximation ratio of 1/3 (in expectation) by ordering the items randomly, and this simple strategy gives the best possible polynomial-time approximation if the unique games conjecture is true. It is also possible to use semidefinite programming or combinatorial methods to find an ordering that satisfies at least half of the triples of any satisfiable instance, in polynomial time.

In parameterized complexity, the problem of satisfying as many constraints as possible from a set C of constraints is fixed-parameter tractable when parameterized by the difference q − |C|/3 between the solution quality q found by the parameterized algorithm and the |C|/3 quality guaranteed in expectation by a random ordering.

Although not guaranteed to succeed, a greedy heuristic can find solutions to many instances of the betweenness problem arising in practice.

References