
So ive been wanting to generate a perfect maze! So i wanted to use the recursive divison algorithm. However, I dont really get how the algorithm will generate a perfect maze, i dont know what im ...

Could you please let me know how to fix the output to be 5? This is a Hackerrank challenge in C++.
Input:
...

I have coded a greedy recursive algorithm to Find minimum number of coins that make a given change. Now I need to estimate its time complexity. As the algorithm has nested "ifs" depending on the same ...

I have a problem with efficent when I try to append readed images using cv2 library.
My readed img are 200,200,3 ndarray.
When I try append about 14k images to created empty array using np.empty((200,...

I need to create a function that takes a number and returns palindrome of this number, by summing its reverse number. For example 312 + 213 = 525. But what's more important, I must use recursion in ...

Does the OS have visibility into the call stack (e.g. calls made between functions) in CPython? E.g. In what way is the OS involved in the creation, retrieval and/or management of the Python stack and ...

Looking at discussion for this coding problem:
https://leetcode.com/articles/jumpgame/
I'm trying to clear the confusions I have by finding the relationships (not the definitions) between ...

I'm trying to build a BST (binary search tree) with dict in python. I do not understand why my code is not adding nodes to the BST. I saw a similar post here:
How to implement a binary search tree in ...

I have python code to find all the possible choices from the list of lists. But when I have a big size list it gives a larger possible dataset. My function is,
def yield_combos(lst):
if not lst:
...

I was wondering that say given an arrangement of valid tower of Hanoi pegs, for example suppose peg [2,2,0] or peg [0,2,1] (let's say the the index of the array are identifiers of each peg, the peg ...

I am trying to create a function that returns a powerset (all subsets of a given tuple of numbers) in the form of a tuple of tuples.
I have followed code that I have found previously, but this ...

Consider the following example:
#include <cstdio>
template <int N>
int fib = fib<N  1> + fib<N  2>;
template <> int fib<2> = 1;
template <> int fib<1&...

I would like to get all integer keys at a given depth/level of a tree.
The solution I tried looks like this:
public LinkedList<Integer> keysAtDepth(int depth) {
return getGivenLevel(depth, ...

I watched a video where they prove T(n)= T(n1) + n is O(n^2)
I have the following expressions which are:
T(1) = 4
T(N) = T(N – 1) + N + 3, N > 1
My question is, is the expression above solved ...

I am trying to traverse a BST PreOrder recursively but I can not make it work. This is what I've tried:
public String PreOrder() {
return preOrderStringBuild(root, "");
}
public String ...

So I'm practicing java currently, I'm a beginner and I try to explain all the examples that I code so I can understand how and why things are like that. I understand the concept of recursion but I ...

Basically I wrote a script which has a class four_in_a_row which has functions to check if someone won, claim a point for a player and print the current status of the game(where which "coins" are). I ...

I know, there are several similar topics, but i was not able to transform the other solutions to my own problem. Here is what i have:
loadMoreMovies(page: number, query: string, genres: Genre[]): ...

Hi I am currently trying to solve the following problem:
Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of ...

here are 2 functions (minor and minors) that I wrote which give same result but miniors gives me an error that is index out of range, please help me understand my mistake
deter=[[1,2,1,1],
[0,...

I was wondering what I am doing wrong with my get method. I've done this before using loops but I cant seem to get the same using recursion. My size() method works with recursion but I am very ...

For the below recursive problem implemented in GoLang:
package recursion
import (
"fmt"
"strconv"
)
// m is the number, n is uptolength of subsequences
// m = 20125, n =3 should print 201,...

I have tried implementing the divide and conquer technique of binary search using recursion. The code for it can be seen below. I think when the program is run, I'm getting stack overflow. If anyone ...

I have setup a Django mptt tree which is displaying the tree correctly. The nested tree consists of 2 types of objects (reseller and customer  added in model). The reseller menu can be nested before ...

I was solving a problem on Hackerrank where I got error maximum recursion depth exceeded. Is it okay to increase the recursion limit or that should be avoided?
Also what adverse effect does it bring ...

deepSearchObject(obj) {
let duplicateExists = false;
Object.keys(obj).forEach(key => {
if(key === 'fieldCode') {
let value = obj[key]
if(this.fieldCodes.includes(value)) {
...

i am unable to guess the output after 'Hello 1' below. Why does system print 09 integers?
public static void number(int count) {
if(count==0)
return;
else {
...

(I'm a total beginner)
I want to write a recursive function which can tell me if a number is a prime number or not: but I keep getting the same recursion error :
here is my code :
from math import *
...

Given n, take the sum of the digits of n. If that value has more than one digit, continue reducing in this way until a singledigit number is produced. This is only applicable to the natural numbers.
...

I have this recursive function, and I try to pass the result in 's' variable.
However if I use *s=*s+v[i]; the function works.
But if I try to call sum(v,i+2,s+v[i],n); It doesn't work anymore.
Can ...

In this function that I use to search some element in a tree ,how can I stop the recursion when I found the seached element?
public function find($element, $found_path){
var_dump($element>...

For the lab problem of insects combinatorics, below is my solution using tree recursion:
func Paths(m int, n int) int {
length := m
width := n
var f func(int, int) int
f = func(h ...

I want to arrange array elements in hierarchy base on [parent_page] key.
the element which have parent_page =0 will be root elements and all other array elements will fall under child key of its ...

Problem Statement
Suppose there is a staircase that you can climb in either 1 step, 2 steps, or 3 steps. In how many possible ways can you climb the staircase if the staircase has n steps? Write a ...

Here is the question:
There are n switches in the campus. You are required to create a mesh topology for the switches. Write a recursive method to returns the total number of connections required for ...

I've written a C++ code which computes failure links in KMP algorithm, but what I really need is to write this code in a recursive way and I have no idea how to do this. I know about recursion, but I ...

I have looked at this long and hard. I understand recursion, I understand the call stack and the concept of “Last in, first out” but in this example.
function countup(n) {
if (n < 1) {
...

Please correct me if I am wrong but I could not find anything straight forward like this online.
Assuming you have the following:
static Func<int,int> GetInt(int n)
{
...

Mind the following function:
function count(n) {
if (n === 0) {
return 0;
} else {
return 1 + count(n  1);
}
}
It is the simplest recursive function that counts from 0 to N. Since ...

Two players take turns choosing one of the outer coins. At the end we calculate the difference
between the score two players get, given that they play optimally.
The greedy strategy of getting the ...

For example there are 3 then the program will
multiplying the first 3 factorials 2 x 4 x 6 = 48. For example if the user wants 3 then the program will multiply the first 3 factorials only and the sum ...

I'm practicing recursion, and am trying to use it to constantly add individual digits in a number until there is only 1 digit left.
Basically, if the number is 84, it becomes 8+4 = 12 which then ...

def digital_root(n):
s=0
if n < 10:
return n
else:
while n>0:
s+=n%10
n=n//10
digital_root(s)
I am having trouble submitting this ...

is Dyanamic Programming helpful only in recursive problems , Can it be used in Some other use cases or problems?

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 I would like remove an item/branch of the tree in each level.
...

I am trying to write a predicate that ‘exists’ inside the ‘scope’ of another predicate . The reason I need this is because both predicates make use of the same very large parameters/arrays and the ...

I am wondering how I turn this piece of code so it only uses pure recursion, so no for or while loops and list comprehension.
def things(list1, list2):
stuff = []
for thing1 in list1:
...

I got an error as "string index out of range" on running code in the command line while it gives the " invalid syntax" as the error in VS code terminal here is my code
def copy(lst1, lst2 = []):
...

I made this code to generate all unique substrings given a string, and I'm struggling to find the complexity of the code when I use recursion. I think a good complexity of time for this problem is O(N²...

The task is to go through a list, compare it with a value and then return the amount of times the value occurred. The comparison works and when I find the matching value I want to save it in a list. ...