Skip to content

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 …

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…

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 clas…