Skip to main content

Testing if an Array Is Sorted

  • Living reference work entry
  • First Online:
Encyclopedia of Algorithms
  • 257 Accesses

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})\)be the input...

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Institutional subscriptions

Recommended Reading

  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–267

    Google Scholar 

  2. Berman P, Raskhodnikova S, Yaroslavtsev G (2014) L p -testing. In: Shmoys DB (ed) STOC, New York. ACM, pp 164–173

    Google Scholar 

  3. Bhattacharyya A, Grigorescu E, Jung K, Raskhodnikova S, Woodruff DP (2012) Transitive-closure spanners. SIAM J Comput 41(6):1380–1425

    Article  MATH  MathSciNet  Google Scholar 

  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–320

    Google Scholar 

  5. Chakrabarty D, Seshadhri C (2013) Optimal bounds for monotonicity and Lipschitz testing over hypercubes and hypergrids. In: STOC, Palo Alto, pp 419–428

    MATH  Google Scholar 

  6. Dodis Y, Goldreich O, Lehman E, Raskhodnikova S, Ron D, Samorodnitsky A (1999) Improved testing algorithms for monotonicity. In: RANDOM, Berkeley, pp 97–108

    Google Scholar 

  7. Ergün F, Kannan S, Kumar R, Rubinfeld R, Viswanathan M (2000) Spot-checkers. J Comput Syst Sci 60(3):717–751

    Article  Google Scholar 

  8. Ergün F, Kumar R, Rubinfeld R (2004) Fast approximate probabilistically checkable proofs. Inf Comput 189(2):135–159

    Article  MATH  Google Scholar 

  9. Fischer E (2004) On the strength of comparisons in property testing. Inf Comput 189(1):107–116

    Article  MATH  Google Scholar 

  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–483

    Google Scholar 

  11. Goldreich O, Goldwasser S, Lehman E, Ron D, Samorodnitsky A (2000) Testing monotonicity. Combinatorica 20(3):301–337

    Article  MATH  MathSciNet  Google Scholar 

  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

    Chapter  Google Scholar 

Download references


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.

Author information

Authors and Affiliations


Corresponding author

Correspondence to Sofya Raskhodnikova .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2015 Springer Science+Business Media New York

About this entry

Cite this entry

Raskhodnikova, S. (2015). Testing if an Array Is Sorted. In: Kao, MY. (eds) Encyclopedia of Algorithms. Springer, Berlin, Heidelberg.

Download citation

  • DOI:

  • Received:

  • Accepted:

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Online ISBN: 978-3-642-27848-8

  • eBook Packages: Springer Reference Computer SciencesReference Module Computer Science and Engineering

Publish with us

Policies and ethics