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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Author information
Authors and Affiliations
Rights 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)