Skip to main content
  • 7276 Accesses

Abstract

For a given problem, it is essential to compare different programs and algorithms in terms of efficiency and/or accuracy. Efficiency refers to the speed of programs and algorithms, as well as the amount of memory required by them. For both speed and memory usage, the efficiency of a program/algorithm naturally depends on its inputs. In order to compare the efficiency of programs and algorithms, we need to analyze them by estimating or measuring their time and/or memory costs. Estimations are as important as measurements; because, we often need to know the cost of a program before writing and using it. In addition, we would like to know the cost when different computers are used, rather than relying on a measurement on a specific computer. Consequently, it is not surprising that calculating costs of programs and algorithms has become a major area in computer science. In this chapter, we use a systematic approach to understand and estimate costs of programs and algorithms. We start with a rigorous analysis by counting each operation and each piece of storage in programs. When these costs are stated as functions of input sizes (and sometimes input values), the resulting expressions are called time and memory complexities. Then, we simplify these expressions using asymptotic techniques, leading a very important concept, namely, the order. After some practices, we derive shortcuts to calculate the orders of programs and algorithms by finding critical lines and items in the codes.

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

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 54.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2013 Springer-Verlag London

About this chapter

Cite this chapter

Ergül, Ö. (2013). Complexity of Programs and Algorithms. In: Guide to Programming and Algorithms Using R. Springer, London. https://doi.org/10.1007/978-1-4471-5328-3_4

Download citation

  • DOI: https://doi.org/10.1007/978-1-4471-5328-3_4

  • Publisher Name: Springer, London

  • Print ISBN: 978-1-4471-5327-6

  • Online ISBN: 978-1-4471-5328-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics