Recursion

Recursion is a technique that leads to elegant solutions to problems that are difficult to program using simple loops. Suppose you want to find all the files under a directory that contain a particular word. How do you solve this problem? There are sev…


This content originally appeared on DEV Community and was authored by Paul Ngugi

Recursion is a technique that leads to elegant solutions to problems that are difficult to program using simple loops. Suppose you want to find all the files under a directory that contain a particular word. How do you solve this problem? There are several ways to do so. An intuitive and effective solution is to use recursion by searching the files in the subdirectories recursively.

H-trees, depicted in Figure below, are used in a very large-scale integration (VLSI) design as a clock distribution network for routing timing signals to all parts of a chip with equal propagation delays. How do you write a program to display H-trees? A good approach is to use recursion.

Image description

To use recursion is to program using recursive methods—that is, to use methods that invoke themselves. Recursion is a useful programming technique. In some cases, it enables you to develop a natural, straightforward, simple solution to an otherwise difficult problem.


This content originally appeared on DEV Community and was authored by Paul Ngugi


Print Share Comment Cite Upload Translate Updates
APA

Paul Ngugi | Sciencx (2024-07-02T18:38:15+00:00) Recursion. Retrieved from https://www.scien.cx/2024/07/02/recursion/

MLA
" » Recursion." Paul Ngugi | Sciencx - Tuesday July 2, 2024, https://www.scien.cx/2024/07/02/recursion/
HARVARD
Paul Ngugi | Sciencx Tuesday July 2, 2024 » Recursion., viewed ,<https://www.scien.cx/2024/07/02/recursion/>
VANCOUVER
Paul Ngugi | Sciencx - » Recursion. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/02/recursion/
CHICAGO
" » Recursion." Paul Ngugi | Sciencx - Accessed . https://www.scien.cx/2024/07/02/recursion/
IEEE
" » Recursion." Paul Ngugi | Sciencx [Online]. Available: https://www.scien.cx/2024/07/02/recursion/. [Accessed: ]
rf:citation
» Recursion | Paul Ngugi | Sciencx | https://www.scien.cx/2024/07/02/recursion/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.