Category "recursion"

How to solve a partition problem using recursion only

I got a partition problem for which I need advice. I'm given a 1D array whose length is even. I need to write a boolean method to determine whether the array ca

How to find all paths recursively from relational table in SQL Server using transitive property?

I would like to be able to recursively find all relationships in a table. I have a relational table, and essentially I would like to apply the transitive proper

#494 Target Sum LeetCode question using Recusion with Memoization

I came across the following question in LeetCode while studying stacks and I'm able to get the brute-force solution. There's a lot of videos + solutions on the

Boolean function returning 24, and acting inconsistent across multiple compilers

Alright, this is driving me nuts and I have no idea what's going on. I have some code I'm making for school that basically takes in a string and a start and end

How to render jsx calling non component function in React?

I adding return before jsx but it stops iteration function App(){ function recursion(object){ for(let key in object){ if(typeof object[key] === 'ob

RecursionError: maximum recursion depth exceeded in comparison : Recursive function

i dont understand why am getting this max depth error . iam trying to find index of number in array using bst recursive approach , below is my code # Binary Sea

Why does converting the factorial function to iterative form by defunctionalizing the continuation give such a bad result?

I'm trying the "defunctionalize the continuation" technique on some recursive functions, to see if I can get a good iterative version to pop out. Following alon

Recursion for max sum in array

I have an array of numbers, A = [2,6,4,7,8,3,2,4,6,3]. I am trying to write an algorithm which recursively finds the max number in the array, however you once y

How do i create a function to convert a binary tree to a tuple?

i came across this question where i was tasked to convert a tuple into binary tree and then convert binary tree back to tuple and return both tree and tuple. i

Calculating a list of valid combinations

So I came up with a problem that I can’t logically solve. I’ve fleshed out an example; You have a list of numbers that you need to output (e.g. 3x n

Recursively creates dataclasses based in nested dictionary

I have a dataclass called Config that is created through the properties and values of a dictionary. Since this dictionary can have nested dictionaries, i would

Soduko solving function takes forever with recursion

class SudokuSolver { // check for string being sudoku validate(puzzleString) { const puzzleArr = puzzleString.split("") const digitCheck = puzzleAr

Recursive map function for nested array

I'm trying to create a map function that supports computing nested arrays, using recursion: This function, when a unidimesional (eg. [1,2,3,4] ) array is used w

Print Diamond shape - Solution in Recursion [closed]

Each line has size 2n+2 The top line begins with n+2 spaces, followed by the uppercase 'o' character, followed by +2 spaces Each lines from

Trying to call a function within a function in Bash but it returns errors

I had looked on overflow and exchange, but I can't seem to find an answer for this. I am currently trying to make a recursive fibonacci function. However when I

Different output on recursive call using static variable [closed]

int fun1(int x){ static int n; n = 0; if(x > 0){ n++; return fun1(x-1)+n; } return 0; } int fun(int x){

Recursion puzzle with key in the box

I currently try to understand recursion on made up example. Imagine you have a briefcase, which can be opened by the key. The key is in the big box, which can c

Deep find object in tree, then return object and the path to it through the tree

I've written a recursive function to find a given object and the path within that tree, but when I change the target id (over here : if(tree.targetModuleId ===

Recursive Function using MPI library

I am using the recursive function to find determinant of a 5x5 matrix. Although this sounds a trivial problem and can be solved using OpenMP if the dimensions a

assertj recursive comparison ignoring regex failing after upgrade from 3.18.1 to 3.21.0

I have updated my springboot , along with that my assertj also seems to have upgraded. Now the test which was initially working in the older version is failing.