[WEBINAR] The New Normal: Dealing with the Reality of an Unsecure World

Recursive Loop

Definition - What does Recursive Loop mean?

A recursive loop is said to have occurred when a function, module or an entity keeps making calls to itself repeatedly, thus forming an almost never-ending loop. Recursive constructs are used in several algorithms like the algorithm used for solving the Tower of Hanoi problem. Most programming languages implement recursion by allowing a function to call itself.

Recursive loops are also known simply as recursion.

Techopedia explains Recursive Loop

A recursive loop is a special type of looping construct where a particular entity tries to invoke itself from within its loop code. Thus the entity keeps calling itself until a specific condition or break is specified. Recursive loops are usually implemented with the help of a recursive function call where a call to a particular function is placed within the function definition itself.

The programming languages capable of implementing recursive loops can solve the problems that require the use of iterative structures like "while" and "for" just by using recursive loops alone. Thus recursive loops can replace the traditional loop constructs and are sometimes useful in creating less bulky code. It also simplifies the code and helps in breaking down complex codes into simple statements.

Some of the most common problem applications of recursive functions include the Tower of Hanoi, computation for series for e = 1/0! +1/1!+1/2+…, computation of gcd, factorial and so on.

Recursion is also used in cases when the programmer is not sure about the exact size of data.

Recursion in computing can be classified into the following types:

  • Single recursion
  • Multiple recursion
  • Indirect recursion
  • Anonymous recursion
  • Structural recursion
  • Generative recursion

Using recursive loops may affect the performance of the program. Recursive loops make use of memory stacks and when the stacks are full, the loop may terminate before the intended termination time.

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
"Techopedia" on Twitter

Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Free Whitepaper: The Path to Hybrid Cloud
Free Whitepaper: The Path to Hybrid Cloud:
The Path to Hybrid Cloud: Intelligent Bursting To Amazon Web Services & Microsoft Azure
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.