All Questions
613 questions
0
votes
1
answer
56
views
understanding a part of recursion for a binary search tree
Hello I basically need to implement a recursive function for insertion of a binary tree. I already implemented the chunk of insertion function (wether it's largest or smaller than root) but there's an ...
1
vote
2
answers
100
views
Finding Longest Almost Palindromic Subsequence (Recursive Solution)
I am working on a problem where I need to find the longest subsequence of a given array that can form a palindrome by removing exactly one element. The solution needs to be implemented recursively.
...
0
votes
2
answers
80
views
How to insert the result of a recursive method into an array in Java?
I'm a beginner to Java and am having trouble figuring out what's wrong with my code here. I get an error message that says my method must return a result of type int[], but am not sure how to proceed.
...
0
votes
2
answers
62
views
linear search in 3x3 array using recursion
I am trying to search for a specific number in a 3x3 int array using recursion, but I don't know why the inner function never return a true value even though it should. How can I fix my code?
...
2
votes
4
answers
153
views
Moving even elements to the front of an array while keeping relative order
public static void teePaarisPaaritud(int[] a){
teePaarisPaaritudRek(a, 0);
}
private static void teePaarisPaaritudRek(int[] a, int i) {
if(i == a.length-1) return;
if(a[i] % 2 != 0){
...
-1
votes
1
answer
67
views
Finding all possible paths in java recursion
When I call the function which finds all the paths to reach the right bottom of the matrix using a recursive approach, it was updating the visited paths to -1 so that it will not loop, but in Java if ...
0
votes
1
answer
91
views
Array element is "9" when printed but not equals 9 in a comparison (==)
the code tells if the sum of every other element in an array of int (input 2) is equal to target (input 3).
public static boolean groupNoAdj(int start, int[] nums, int target) {
if (nums.length<=...
-1
votes
1
answer
62
views
Java Recursion problem , cant handle edge cases - due to ArrayIndexOutoOfBound
import java.util.Arrays;
public class DSA_First_Last_Occurence_Rec {
public static void main(String[] args) {
int[] arr = {2,2};
int ae = 2;
System.out.println(Arrays....
0
votes
2
answers
94
views
How can I transform this method in a recursive call?
I have this method and I would to transform it in a recursive call.
public double findDeltaL(Point[] pl) {
double delta = Math.sqrt(Math.pow(FTCPPanel.WIDTH, 2) + Math.pow(FTCPPanel.HEIGHT, 2));
...
-1
votes
2
answers
79
views
Recursion method is invoked even after loop condition is met
public int removeMin(Integer[] arr, int count) {
Integer[] tempArr = new Integer[arr.length -1];
int index = 0;
for (int i = 1; i<arr.length; i++) {
tempArr[index] = arr[i] ...
-1
votes
1
answer
38
views
Finding time complexity of a recursion code
The code is written in Java. Here, I am reversing an integer array using recursion.
I am unable to find the time complexity of the below code:
class Test2 {
public static int[] reverse(int[] arr, ...
-1
votes
1
answer
40
views
Recursively Reverse an Array using Global Variables
I'm not too sure how I can modify start and end when they're not in the recursive method?
For this example, I'm trying to reverse an array.
Usually end up getting StackOverflow Error for my test so ...
0
votes
2
answers
199
views
Combination of all characters of a string with other characters of string inside a string array
Suppose I'm given the following array:
{"abc", "mno", "pqrs"}
Now I need to get all the possible combinations from the characters of elements of the array.
The output ...
2
votes
0
answers
151
views
Creating a non-Attacking Queens game that is supposed to print out all 92 solutions of 8 queens on a chess board that cannot attack eachother
I made the 8x8 chess board and have a lot of the code done, but for some reason it only print out one solution, does anyone know why this may be and how I can fix it?
public class NonAttackingQueens {
...
0
votes
0
answers
93
views
How do I find the number of order of a specific number in a sequence of numbers?
So I have a task in university. I have to write a Java program which allows to to input numbers starting from 0 and the specific count of said numbers. Then the numbers are arranged in an increasing ...