Skip to content

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.

License

Notifications You must be signed in to change notification settings

jabrena/101-recursion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

101 recursion

docs

The repository review Recursion in the context of Java programming language.

What is recursion?

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.

recursion

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

What is Tail Call Optimization (TCO)?

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

Concepts

Tail Recursion

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

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

Divide and Conquer is a recursive algorithmic strategy that breaks down a problem into smaller subproblems until they become simple enough to solve directly.

Utils

How to build in local

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

References

Recursion in Java

Recursion in other programming languages

Property-Based Testing, PBT

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Languages