Tail Recursion

Tail Recursion in JAVA 8

Reading Time: 3 minutes A tail-recursive function is just a function whose very the last action is a call to itself. Tail-Call Optimisation(TCO) lets us convert regular recursive calls into tail calls to make recursions practical for large inputs, which was earlier leading to stack overflow error in normal recursion scenario. With Scala, making a tail recursive function is easy. The Scala compiler detects tail recursion and replaces it with Continue Reading

Jump Higher With Trampoline

Reading Time: 6 minutes In our earlier blog The Tale of ‘Tail Recursion’, we have talked about tail recursion. And In this blog, we will be talking about limitation of tail recursion and its solution in scala. Unfortunately JVM doesn’t support tail call optimization, but scala does as we have seen. However, what if we are not doing simple tail recursion like we usually do. What if on the Continue Reading

The Tale of ‘Tail Recursion’

Reading Time: 3 minutes Recursion in computer science is a method where the solution to a problem depends on solutions to smaller instances of the same problem (as opposed to iteration). Recursions are really cool and they are highly expressive. For example consider factorial function: But if i increase the size of input, code will blow up. Recursions don’t scale very well for large input sizes. And in practical Continue Reading

Knoldus Pune Careers - Hiring Freshers

Get a head start on your career at Knoldus. Join us!