# Encyclopedia of Algorithms

Living Edition
| Editors: Ming-Yang Kao

# Testing if an Array Is Sorted

Living reference work entry
DOI: https://doi.org/10.1007/978-3-642-27848-8_700-1

## 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 $$a = (a_{1},\ldots ,a_{n})$$

## Keywords

Property testing, Sublinear-time algorithms, Monotonicity, Sorted arrays
This is a preview of subscription content, log in to check access.

## Notes

### Acknowledgements

The author was supported in part by NSF CAREER award CCF-0845701 and Boston University’s Hariri Institute for Computing and Center for Reliable Information Systems and Cyber Security.

1. 1.
Ben-Moshe S, Kanza Y, Fischer E, Matsliah A, Fischer M, Staelin C (2011) Detecting and exploiting near-sortedness for efficient relational query evaluation. In: ICDT, Uppsala, pp 256–267Google Scholar
2. 2.
Berman P, Raskhodnikova S, Yaroslavtsev G (2014) L p-testing. In: Shmoys DB (ed) STOC, New York. ACM, pp 164–173Google Scholar
3. 3.
Bhattacharyya A, Grigorescu E, Jung K, Raskhodnikova S, Woodruff DP (2012) Transitive-closure spanners. SIAM J Comput 41(6):1380–1425
4. 4.
Blais E, Raskhodnikova S, Yaroslavtsev G (2014) Lower bounds for testing properties of functions over hypergrid domains. In: IEEE 29th conference on computational complexity (CCC) 2014, Vancouver, 11–13 June 2014, pp 309–320Google Scholar
5. 5.
Chakrabarty D, Seshadhri C (2013) Optimal bounds for monotonicity and Lipschitz testing over hypercubes and hypergrids. In: STOC, Palo Alto, pp 419–428
6. 6.
Dodis Y, Goldreich O, Lehman E, Raskhodnikova S, Ron D, Samorodnitsky A (1999) Improved testing algorithms for monotonicity. In: RANDOM, Berkeley, pp 97–108Google Scholar
7. 7.
Ergün F, Kannan S, Kumar R, Rubinfeld R, Viswanathan M (2000) Spot-checkers. J Comput Syst Sci 60(3):717–751
8. 8.
Ergün F, Kumar R, Rubinfeld R (2004) Fast approximate probabilistically checkable proofs. Inf Comput 189(2):135–159
9. 9.
Fischer E (2004) On the strength of comparisons in property testing. Inf Comput 189(1):107–116
10. 10.
Fischer E, Lehman E, Newman I, Raskhodnikova S, Rubinfeld R, Samorodnitsky A (2002) Monotonicity testing over general poset domains. In: STOC, Montreal, pp 474–483Google Scholar
11. 11.
Goldreich O, Goldwasser S, Lehman E, Ron D, Samorodnitsky A (2000) Testing monotonicity. Combinatorica 20(3):301–337
12. 12.
Raskhodnikova S (2010) Transitive-closure spanners: a survey. In: Goldreich O (ed) Property testing. Lecture notes in computer science, vol 6390. Springer, Berlin, pp 167–196