... E.W. Dijkstra, since he would have appreciated the problem and would probably have solved it nicer than we can do below. Our problem is about three ascending sequences of numbers. It was inspired by =-=[2]-=-, exercise C-3.1 (p. 213), which is about two ascending sequences. In order to formulate the problem and its solution, we need some notation on sequences. If s is a sequence of length N, we denote its...

...to eliminate instead. We have chosen the name “ternary search” because of the three sequences involved and the analogy of binary search. Just as in Dijkstra’s favourite treatment of the binary search =-=[1]-=-, the assumption that the sequences are ascending, is not used for preservation of the invariant, but only in the interpretation of the postcondition. If one wants to weaken the assumption m ≤ N to th...