Index of first distinct character between two strings using a recursive method

I need to find the index of the first distinct character between two strings using a recursive method. Examples with expected outputs: rFirstDistinctPlace(“Little parcels”, “Little …

Analysis of recursive approach for rotating an array of integers

While solving Array rotation on LeetCode, I wrote a recursive algorithm to solve the problem: Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Input: nums …

StackOverflowError on recursive algorithm

I’m trying to code a recursive algorithm in order to generate a valid board(unique solution) for a game called kakuro. When executing the program I keep getting a StackOverflowError. I tried debugging …

Array from recursive call being overwritten

We’re making a program to solve an asterisk sudoku via a recursive approach with back tracking. The solveIt method calls the solve method which is the recursive method. grid is declared before to be a …

Finding the Base 2 Logarithm of a number using Recursion in java

I’m trying to write a recursive method in Java to find the base 2 log for multiples of 2. I’ve successfully computed the log using this recursive method. import java.util.*; class temp { static …

what is wrapper function and how to use it?

For my homework, I am required to use a function called wrapper function to validate the parameter for a recursive function, which I don’t understand what it means. All i understand from wrapper …

how recursive function works level by level?

I have trouble on understating how recursion works, I have been struggling this for a while! Could anyone can help me with this? I’d really appreciate that, and here is the code for instance: public …

How to calculate RECURSIVELY 2D array column in Java

I am stuck with a homework question for something fairly stupid. The mission is to find the smallest column sum on a 2D array and return it’s index. No loops allowed, only recursion. I managed the …

Recursion problem – is this solution correct, and is there a simpler one?

I am new to recursion and I found the following Java problem: Write a function that gets an integer n, and prints the numbers 1!,2!,3!,…,n!. Here is what I did and I would like to know if this is …

How to make this recursive function faster in Python or Java?

I have this recursive function: F(n)=4F(n-1)+F(n-2), for all n>=2, where F(0)=0 and F(1)=1. This is my code in python def f(n): res = 0; if n == 0: return 0 elif n == 1: …