Skip to main content
  • 7260 Accesses

Abstract

A recursion is a repeating process, where a statement is used inside itself. Recursive algorithms are very useful in computer programming, and in many cases, the most efficient program to solve a given problem involves a recursion. For example, one of the most efficient sorting algorithms, namely the quick sort algorithm, is also based on a recursive structure. In this chapter, we again start with simple examples to implement recursions, along with some possible mistakes. Then, we see how recursions can be used effectively to solve more complex problems. Some examples presented in this chapter are finding the highest common factor and lowest common multiple of a set of integers, Towers of Hanoi, binary search, sequence generation, and computing determinants of matrices. Despite their favorable properties, one should be very careful when implementing recursive algorithms since they can easily go out of control. All recursive structures require termination conditions that must be placed accordingly into programs. Constructing tree structures using simple examples can be very useful when understanding and writing recursive programs. Such a tree structure may also provide some information on the efficiency of a recursive program by showing the depth of recursion in terms of inputs. Finally, at the end of the chapter, we consider a very important concept, namely proof by induction, which is a mathematical tool to analyze and understand recursive expressions.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.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). Recursions. In: Guide to Programming and Algorithms Using R. Springer, London. https://doi.org/10.1007/978-1-4471-5328-3_3

Download citation

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

  • 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