Tail Recursion

Why Trust Techopedia

What Does Tail Recursion Mean?

Tail recursion is the act of calling a recursive function at the end of a particular code module rather than in the middle. A function is recursive if it calls itself. This programming concept is often useful for self-referencing functions and plays a major role in programming languages such as LISP.

Advertisements

Techopedia Explains Tail Recursion

In computer programming, a function that calls itself, either directly or indirectly, is a recursive function. When this call happens at the end of the function, it is called tail recursion. Usually, other calculations or procedures are done before the recursive call.

A tail recursion usually occurs when a recursive function call is made, then ends, and has nothing else to do after having done the recursive call. The benefits of this approach include less burden of retaining a stack frame, as well as code readability. Programmers and designers sometimes use tail recursion in order to optimize code and maximize efficiency.

Advertisements

Related Terms

Margaret Rouse
Technology expert
Margaret Rouse
Technology expert

Margaret is an award-winning writer and educator known for her ability to explain complex technical topics to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles in the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret’s idea of ​​a fun day is to help IT and business professionals to learn to speak each other’s highly specialized languages.