Dscs221 When should you consider using recursive algorithms when writing a program? PDF

Title Dscs221 When should you consider using recursive algorithms when writing a program?
Author Anwar Sadat
Course Programming 2
Institution University of the People
Pages 1
File Size 63.2 KB
File Type PDF
Total Downloads 58
Total Views 130

Summary

There are several times where a recursive algorithm is required during the development of a program, requiring a thorough understanding of recursion and its principles. Recursion, on the other hand, has certain benefits and drawbacks, but the benefits mostly outweigh the drawbacks. I will try and di...


Description

When should you consider using recursive algorithms when writing a program? There are several times where a recursive algorithm is required during the development of a program, requiring a thorough understanding of recursion and its principles. Recursion, on the other hand, has certain benefits and drawbacks, but the benefits mostly outweigh the drawbacks. I will try and discuss some of the benefits and drawbacks of using recursive algorithms when writing programs. One of the most significant benefits of using a recursive algorithm in program writing is that it eliminates the risk of repetitive method calls, which can otherwise be introduced when using iterations. Instead of a much bigger redundancy solution, it is a simple approach to solve problems. It cuts down a large portion of the challenge into smaller pieces that are simpler to tackle. In addition, the function returns for itself, calling itself back. When traversing nodes, particularly in cases involving related data structures, the recursive algorithm approach is extremely useful. The recursion algorithm cuts down on the time it takes to write a program and debug it. One of the key drawbacks to using a recursive algorithm is that if a function in a computer has the ability to call itself too many times, it can affect the device's memory space, potentially causing the program to crash. This allows the stack to use more memory. Furthermore, a recursive solution is still rational, and it has the potential to reduce execution time.

References: Eck, D. J. (2019). Introduction to programming using Java, version 8.1. Hobart and William Smith Colleges. http://math.hws.edu/javanotes...


Similar Free PDFs