K-sorted sequence
In computer science, a nearly-sorted sequence, also known as roughly-sorted sequence and as k {\displaystyle k} -sorted sequence is a sequence which is almost ordered. By almost ordered, it is meant that no element of the sequence is very far away from where it would be if the sequence were perfectly ordered.