Category "recursion"

How to check whether all number elements in an array are even numbers with recursion?

I'm currently learning as much as I can about recursion but I'm really stuck on how to use it to check whether all the number elements in an array are even numb

Converting Complex Tree Structure to JSON Python

I need to convert a Tree with the following class structure: Class Tree: def __init__(self, data): self.data = data s

tail recursion count, split & get the prefix of a list functions

Language: Scala I'm working on some tail recursion questions in Scala. (GOAL) A function that counts the number of ones in a list. The function takes a list of

Flatten nested list and retain all parent keys for each bottom-level element

I need to flatten an arbitrarily nested list to a data frame and retain the path of keys / indices in one column, while extracting each element on the bottom le

The code works but not for all of the inputs

I have an assignment in recursion. The problem: A game board is defined by a list. Each list index, (0: n-1) is a row in the board, and the int value in each li

Recursively find files with a specific extension and copy them to a new directory with new names

I tried to find all the .xvg files generated by Gromacs inside a directory as well as its subdirectories and then copy them to a new directory, with new names f

Method to recursively search for a file in directory and subdirectories doesn't find the file

I wrote a function to find a file in a specific directory and its sub-directories. You can input the filename with or without extension (basename vs. filename).

Adding logs within a wrapped function

I have created a function wrapper to help give me various print statements: function fnWrapper(fn, verbosity=false) { return function(...rest) {

"put together" output through recursion in Haskell

I really don't know how to properly describe my problem. I have an assignment to do and as part of that I need to take a list and return a new list that is an a

A basic C++ recursion question I can't wrap my head around

I am learning the basics of CPP programming. I came across this basic recursion question which I'm unable to understand. The output is 1 2 3 4 5 but I don't und

Improve debugging output of a recursive function

I have the following recursive function to count the number of ways change can be returned given various coin denominations: function makeChange(amount, coi

Improve debugging output of a recursive function

I have the following recursive function to count the number of ways change can be returned given various coin denominations: function makeChange(amount, coi

Recursively update nested object values for specific keys based on another object

*** UPDATED object structure *** I'd like to update recursively the property values of mainObject from the properties that exist in updatingObject. let mainObje

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