Skip to content
Advertisement

Tag: recursion

Permutations with duplicates

Before I start, I have to apologize for bringing up another case of permutations with duplicates. I have gone through most of the search results and can’t really find what I am looking for. I have read about the Lexicographical order and have implemented it. For this question, I am suppose to implement a recursion method that prints out the

Java recursive Fibonacci sequence

Please explain this simple code: I’m confused with the last line especially because if n = 5 for example, then fibonacci(4) + fibonacci(3) would be called and so on but I don’t understand how this algorithm calculates the value at index 5 by this method. Please explain with a lot of detail! Answer In fibonacci sequence each item is the

Create a triangle out of stars using only recursion

I need to to write a method that is called like printTriangle(5);. We need to create an iterative method and a recursive method (without ANY iteration). The output needs to look like this: This code works with the iterative but I can’t adapt it to be recursive. I should note that you cannot use any class level variables or any

Is there any way to do n-level nested loops in Java?

In other words, can I do something like Except N times? In other words, when the method creating the loops is called, it is given some parameter N, and the method would then create N of these loops nested one in another? Of course, the idea is that there should be an “easy” or “the usual” way of doing it.

Advertisement