Living Reference Work Entry

Encyclopedia of Algorithms

pp 1-5

Date: Latest Version

Testing if an Array Is Sorted

  • Sofya RaskhodnikovaAffiliated withComputer Science and Engineering Department, Pennsylvania State University Email author 


Property testing, Sublinear-time algorithms, Monotonicity, Sorted arrays

Years and Authors of Summarized Original Work

2000; Ergün, Kannan, Kumar, Rubinfeld, Viswanathan2014; Berman, Raskhodnikova, Yaroslavtsev

Problem Definition

Suppose we would like to check whether a given array of real numbers is sorted (say, in nondecreasing order). Performing this task exactly requires reading the entire array. Here we consider the approximate version of the problem: testing whether an array is sorted or “far” from sorted. We consider two natural definitions of the distance of a given array from a sorted array. Intuitively, we would like to measure how much the input array must change to become sorted. We could measure the change by:
  1. 1.

    The number of entries changed

  2. 2.

    The sum of the absolute values of changes in all entries


It is not hard to see that looking at the number of entries that must be deleted in an array to make it sorted is equivalent to the measure in item 1.

To define the two distance measures formally, let ...

This is an excerpt from the content