The repository review Recursion in the context of Java programming language.
Recursion is a programming technique where a function calls itself to solve a problem. It is a way to solve problems by breaking them down into smaller, more manageable parts.
In the repository you will find examples of recursion in Java.
- Simple Java recursion
- Tail Call Optimization (TCO)
- Memoization
- Divide and Conquer
- Emulate recursion with Java stream API
- Detect issues with Stacktraces
Tail Call Optimization (TCO) is a compiler optimization technique that converts recursive tail calls into iterative loops. A tail call occurs when a recursive call is the last operation in a function.
what is the key benefits of TCO?
- Prevents stack overflow by reusing stack frames
- Improves memory usage and performance
- Turns recursion into iteration under the hood
Note: While Java doesn't support TCO natively, other JVM languages like Scala or Kotlin and functional programming languages do.
In JDK classes there are a number of security sensitive methods that rely on counting stack frames between JDK library code and calling code to figure out who's calling them.
Source: https://stackoverflow.com/questions/53354898/tail-call-optimisation-in-java#53354956
Tail recursion is a special type of recursion where the recursive call is the last operation performed in the function. In other words, there are no pending calculations after the recursive call.
Memoization is a technique used to optimize recursive functions by storing the results of expensive function calls and reusing them when the same inputs occur again.
Divide and Conquer is a recursive algorithmic strategy that breaks down a problem into smaller subproblems until they become simple enough to solve directly.
sdk env install
./mvnw clean verify
./mvnw clean test -Dtest=InfiniteRecursionTest
./mvnw clean verify surefire-report:report
./mvnw clean verify jacoco:report
./mvnw versions:display-dependency-updates
./mvnw versions:display-plugin-updates
- https://www.geeksforgeeks.org/recursion-practice-problems-solutions/
- https://medium.com/@johnmcclean/trampolining-a-practical-guide-for-awesome-java-developers-4b657d9c3076
- https://github.com/aol/cyclops
- https://github.com/bodar/totallylazy