Run of a sequence
In computer science, a run of a sequence is a non-decreasing range of the sequence that cannot be extended. The number of runs of a sequence is the number of increasing subsequences of the sequence. This is a measure of presortedness, and in particular measures how many subsequences must be merged to sort a sequence.
Definition
Let be a sequence of elements from a totally ordered set. A run of is a maximal increasing sequence. That is, and assuming that and exists. For example, if is a natural number, the sequence has the two runs and.Let be defined as the number of positions such that and. It is equivalently defined as the number of runs of minus one. This definition ensure that, that is, the if, and only if, the sequence is sorted. As another example, and.