# Recursion Questions

## C - recursion not working in a Binary Search Tree

I'm implementing a bst in c. if the tree only has 2 leaves and nothing in between, recursion works. but as soon as it goes deeper (eg below 3

## How recursion return the value?

1. #include<stdio.h> int recursion_check(int i); main(){ printf("%d",recursion_check(6)); }

## Inverse of a sentence using putchar() in a recursive function

I came into this code reading some slide, just code without explanations, and i can't understand how the invertseq function works. especially how

## Recursive Binary Search Program C

The following code works good if the key is less than equal to 11 but if the key is greater than 11 it does not return anything.

## How does recursion work when inserting nodes in linked lists?

I have trouble understanding how these functions work:

## Is recursion preferred in this situation?

Suppose we have a string of characters and we want to print it in reverse order. recursion seems to be the faster choice in this case because the

## Explanation of this recursive function of Fast_Modular_Exponentiation

Here is a code form a udemy course that i am currently taking. this piece of code is a recursive solution to solve

## How does recursion work on traversing through a binary tree, and counting the number of list nodes?

I have trouble visualizing these following print and size functions from the following url

## How can I set the number of iterations to run in a recursive function in Matlab?

How can i set the number of iterations to run in a recursive function in matlab? i have the following function function t=m(x1,x2)

## Segmantation fault in recursive function

I am trying to find factorial by recursively.my function works but why i recieve "segmenatation fault (core dumped)" when i input

## Building a Table Dependency Graph With A Recursive Query

I am trying to build a dependency graph of tables based on the foreign keys between them. this graph needs to start with an arbitrary table name

## F# - Recursion with anonymous records

Given the following f# snippet: type a(children: a list) = member val p1 = "" member val p2 = ""

## How do I recursively read properties of an Object

I have the following class. more properties can be added at any time in its life public class foo { public string propertya {

## Why does @tailrec not permit this seemingly tail recursive function?

The helper function here: def zipwith[b]: (mylist[b], (a, b) => b) => mylist[b] = { (list, function) => {

## Recursion for even array in C

I understand there are a lot of questions around even recursion here, but i don't know in c wether its my logic or my syntax that's wrong (or

## Angular 2 : EXCEPTION: Error in app.component.html:1:108 caused by: too much recursion

I have downloaded the angular 2 quickstart and it worked fine after all of the setup. i setup an express server and connected to that and the app

## Remove item recusively from tree

I'm trying to create a tree component. but i dont know how remove a item recursively inside a tree. each item its created dinamically and

## Recursive challenge in JS combining all possible array keys in true | false versions, I attach the input and output

I have found many solutions about all posible combinations between array values but i need something different, i hope you could support me.

## create repetition of elements multidimentional

I am trying to create a repetition of elements given array like this [1,2,10] to get the result by size

## Getting all recursion results in a list

I'm learning about python recursion. to practice i'm giving a task to find all subset of a list. for example the function:

## Create JSX tree from flat Array with recursive function in react

I really need your help to create a jsx tree from a flat array in react using recursive function. for the moment only the items 1 to 6

## Recursion Error for coin change calculator - cannot debug

I'm doing a change calculator - a function that takes in the cost of an item and the amount of money given to the cashier, before returning the

## Check all properties are not null in n-depth POJO

I am needing a function that takes any object and returns true/false if every child meets a condition. currently that condition is that the

## Javascript Recursion inside class method (this behaviour)

The problem lies inside tostring function , this does not actualize the scope as the function calls itself: i need something to solve the problem

## Can't create recursive type `using T = vector<T::iterator>`

I'm trying to create a vector that contains its own iterators as elements, and i find it impossible to fully expand the type declaration.

## Python: Return lists of lists from recursive function

Problem i have a hard time figuring out how to return a nested list from a recursive function. i have a nested structure, from which i

## Python: How to reverse integers using recursion

I am given a problem where i have to reverse given digits using recursion only, but the problem is when i try to print out the integer reversed,

## Use Recursion to Create a CountdownPassed (JS Algorithm)

Question we have defined a function called countdown with one parameter (n). the function should use recursion to return

## Arbitrary depth nested loop

How do i turn the following into a recursive function that can accumulate a list of lists in an arbitrary-depth fashion? def

## What is the logic of the order of the calls, in recursion in Javascript?

I have a hard time understanding the order of the calls in recursive programming in javascript while playing around with recursive

## Code undoes itself before returning value

From time import sleep def refit(i, n, c=[]): sleep(1) print(c) if i[:n] != '': refit(i[n:],n,c+[i[:n]]) sleep(1) print(c) return c

## How to write n times nested loop efficiently?

I have a list of 2d list which row number is 60 and column number is not fixed. here, row numbers mean position. how to get every possible

## Firestore cloud function to recursively update subcollection/collectionGroup

I have this cloud function: import plimit from "p-limit"; const syncnotificationsavatar = async ( userid: string, change:

## Create a combination method recursively

I am trying to implement a combination method using recursion. i have already done it using a for loop but want to approach it via recursion.

## How to fix the recursive function?

It's a simple question of recursive function, which extracting every digits from a positive number. as the comment mentioned, i have known the

## RecursionError is limiting my sort function in big arrays

I need help rewriting some recursion code so i don't run into this error: recursionerror: maximum recursion depth exceeded in

## How to achieve recursive Promise calls in Node.js

I am calling an api where i can only fetch 1000 records per request, i was able to achieve this using recursion. i am now trying to

## How do i call a recursive function in this python program where I am supposed to convert decimal numbers to hexadecimal?

X="" def main(): decimal=int(input("enter a decimal value")) print (decimaltohexa(decimal))

## Replace items in array with elements from a different set

I'm not sure the proper way to go about this recursively. let's say i have two arrays array1 = [a, null, c, d, e] array2 = [1, 2,

## Collatz sequence (endless loop)

Firstly i know this is a very asked question. write a function named collatz() that has one parameter named number. if number is even, then

## Javascript, a simple recursive function

I need help implementing a recursive function. this is my first time attempting recursion outside of the standard 'factorial' that us newbs first

## List of List not retaining the contents

So i have a recursive program where i am trying to generate all the permutations of a string. i intend to store the permutations in a list of list

## DOM traversal without exluded elements

I'm creating a simple script that traverses the dom and returns a tree object with the elements found in the dom. recursive traversal itself is

## Recursive array enumeration in JS

Please tell me how to iterate over an array with unknown nesting? the situation is this, i practice js and reactjs at the initial level, i make an

## Recursive division over a list

I'm looking to divide every element of an list recursivly like this. a_list = [1, 2, 3, 4, 5] so the returns would be 1/(2/(3/(4/5)))

## How can I immediately break from searching through directory recursively once desired file is found?

I'm recursively searching through a directory structure for a file with a specific name. i want to break as soon as the first instance of that

## Lazy mode of recursive function

I'm going to find a solution to this problem: splitting given list to sublist with given sub-list length and skip length, for example:

## Determining if a knight can pass through all cells in a 2d array - if so print board

I need an advice regarding this problem called "knight path". given an n*n board whose cells are initialized to 0, i need to determine,

## Numba jit warnings interpretation in python

I have defined the following recursive array generator and am using numba jit to try and accelerate the processing (based on

## How to execute callback function while resursive function is running in Javascript?

It is impossible to run callback function while recursive function is running? it is sample code of reculsive fibonacci function and

## How to code 'ID of DOM method to using in recursion'?

I have a problem in 'getobjectbyid to using in recursion'. executing the function getobject(data, '11') ---> undefined.

## Unintended recursive loop with __repr__ method

I want to display a list of all accessible attribute of an instance, so i try this class

## Parent Child Relationship in SQL Server 2019

I have a table that stores relationships like this: parentname parentid childname childid -------------------------------------

## How do I split a list on certain conditions in Haskell?

As a programming exercise i'm trying to build a function in haskell where given a list it splits the list whenever an element is repeated.

## Issue in promise based recursive function

I am working on aws lambda using nodejs environment. i have one api in which i am using recursive function for some functionality.

## Counting all descendants in a family tree (python dictionary)

I'm kind of beating my head against a wall here and i'm hoping that someone on stackoverflow can help me. let's say i have a python dictionary

## Create tkinter nested treeview from nested dictionary

I have a nested dictionary like this that i want to use to populate a hierarchical treeview. hierarchy = { 'a': {

## dictionary size changed during iteration (Runtime error)

I get runtimeerror: dictionary changed size during iteration, i went through some of the stack overflow posts and found this happens when you

## How to update nested array recursively using javascript

I have an array which contains: name, id (id represents the path in array) and children

## How to get the last children in a deeply nested array with objects

So let's say i have a deeply nested array and i want to get the deepest nested children and i'm unable to think of a good way to implement it

## Dart - Recursive function returning null

I am trying to create a simple recursive function which generates a random number between 0 & 4 and this generated number should not be equal

## Find the height of tree, where the input tree can have any number of children

Part of my problem is to write a function that determines the height of a tree. this is my current function, def

## Print contents of tree in level-order, using the eval function to read the input tree in python

Part of the problem requires the tree to be printed in level-order, so if the input tree is: ("hello", (("a", ()), ("b", (("cde",

## Extract nested <a> elements from a JSON string

I am trying to find all "a" keys in a json string and save them in an array. since they may be nested at different levels, i'm using recursion to

## Nodejs- Recursive function not being called from inside a successful request call

I have an array of objects. for each element of the array, i need to make a post request. once the post request is successful, i need to get the

## Functional recursive function with reduce

I'm given a sequence tuple(range(1,5)) and i am supposed to write a recursive function with reduce to calculate the product 1*2*3*4*5

## Recursive function without return statement

I have some data that is inserted into a nested dictionary. the data are created and could theoretically be endlessly deep. it could e.g. looks

## How to store values globally in recursive calls in python

I have a doubt regarding backtracking appraoch in python . how do i store the variables and list (temporary) so formed in different calls in

## Aggregate a property containing an array of objects, in a tree data structure

I have a tree structure like below (there is no depth limit, generally not more than 6 sub-levels). each node has a workitems

## Multidimensional array with polymorphic relation (tree structure)

To understand what i want to do, here a simple expain : i want to create templates. one "template" has a "panel" this "panel" has some

## How to keep track of next item in dict (Recursive loop)

I tried, with enumeration() and i var to keep track of the recursive function, unfortunately, the values are misleading.

## How to add an arrow to menu elements that have children?

I am trying to add a fontawesome arrow next to each item in my menu that has children (i.e. i want to indicate that you can click the element to

## Remove Even numbers from stack up to int k

I'm trying to write a recursive function that removes the first k even numbers from the stack. if there are less than k even elements in the

Class nested extends model{ public function nestedfunc() { return \$this->hasmany(nested::class, 'parent_id'); } public function

## What causes an EPERM error when traversing my home directory?

I googled eperm: operation not permitted and i got many hits on issues with npm and this error.

## Recursively trying to find the maximum w/o loops

So i'm given a tuple of ordered pairs in this format: (x,y) where x represents the physical weight of the objects, y

## recursive function how to save messages in array?

I have created recursive function that sorts my nested object, gets messages from it depending on some properties. at the end i want to get an

## Combining recursion with map - is reduce the solution?

I am trying to avoid using a for loop at all costs in this example. consider this simple case: i have a vector z and an

## How can I use modern kotlin functional techniques to solve this recursive loop problem?

I have a kotlin problem, can you come up with a elegant way of solving it? so effectively i have a list of objects which i want to arrange

## Cannot get array of values from recursive javascript function

I am scraping a list of users who liked a post on instagram. the following code runs perfectly fine:

## setTimeout in a Promise - how to resolve and why does it only runs once?

I'd like to simulate mouse scrolling based on random time, with settimeout in a promise. my goal is to keep scrolling down to the webpage's

## Find all combinations of 0, 1 that sum to 1 or 2 at varying lengths / sizes

I would like a function that would return 0, 1 combinations, that sum to 1 or 2, for varying length. i know the total combinations (before

## Better way to map a deep object to new object

This code works for converting the json to an object where each name object turns into the key for either its value, or if it instead has its own

## Break recursive function

In this function i'm trying to find a specific item inside a json string. i can find the item but the issue is that once the item is found i want

## Is there a way to change this nested loop into a recursive loop?

I'm looking for help on the following problem. i have a small program that is part of a much larger program, i need to loop through every

## multilevel dropdown for react recursion

I am building a multilevel menu and want to use recursion to display the menu. something like the multi-level dropdown from

## Questions about Python's recursive function course

I'm implementing an algorithm to find all combinations of m elements out of n. i have verified the entire code through the answer, but

## NodeJS : Loop through nested JSON and remove elements based on a condition

Let's say i have a below object: { "schema": [ { "field": "name", "type": "string", "enabled": true }, { "field": "age",

## Recursively combine dictionaries

Alright, this is doing my head in. i have two dictionaries with object groups as shown below: groups = { 'servers':

## How can I "recursively" stringify a javascript function which calls other scoped functions?

Because javascript functions are not serializable, in order to pass them into new contexts sometimes (albeit rarely) it can be useful to stringify

## Get undefined result while await recursive function

Here is my scenario: in my function, i want to wait for another function for doing some recursive thing and return the result in the end. but i

## How do I generate a recursive tree-like dictionary from a flat file (Gene Ontology OBO file)?

I'm trying to write code to parse a gene ontology (go) obo file and push the go term ids (e.g. go:0003824) into a tree-like nested dictionary. the

## JS | Recurse through nested "for of" Loop

While learning nodejs, i've been battling to write a more concise logic to this code block (see below) that could either introduce

## Unable to debug sum of a list using recursion in Python

Def sumlist(arr): items = len(arr) if(items == 0): return 0 elif(items == 1): return arr[0] else:

## Recursive Alternative/Merge Linked List Function with Multiple Linked List as Arguments?

I'm having trouble working with recursive linked list function with multiple linked list arguments. so far i have came up with below, with

## Smallest number whose digits are decreasing

I found a problem to implement functions that takes a positive integer n as an input and returns the smallest positive integer larger than n whose

## Angularfire2 Observable Recursion

I am attempting to create a "breadcrumbs" list by looping through documents and grabbing their parents. my data structure looks like so:

## Recursive function return tuples of even index values?

Is it possible to return tuples of only even indexes through recursion? this is what i came up with it so far. def