Skip to main content

All 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 ...
Cool Dude's user avatar
-4 votes
1 answer
60 views

Problem with recursive function that sums all numbers in array in Go

I want to sum all the numbers in array using recursive function import ( "fmt" ) func RemoveIndex(s []int, index int) []int { return append(s[:index], s[index+1:]...) } func ...
Tarik's user avatar
  • 1
-1 votes
1 answer
51 views

I am new to recursion, I could not get how this program print the output?

I am assuming that this program should give the output [5,4,3,2,1] but it is giving [1,2,3,4,5]. Why this is happening? How the recursion is working here? Please explain me? function countup(n) { ...
xaviour1504's user avatar
1 vote
4 answers
115 views

Is array B a reversed version of array B function [duplicate]

I need a guidance to understand where my logic is not working. I need to write a recursive function that receives array A, and array B from a user input. The function is checking if the arrays are ...
Must's user avatar
  • 19
0 votes
1 answer
33 views

PHP Category Recursion & Arrays not displaying all results [closed]

I'm using a category system which has parent categories which can have multiple child categories, which can also have child categories and so on... I am trying to use a script which will use the ...
Snappysites's user avatar
0 votes
1 answer
104 views

Can this recursive function be optimized?

Is there a way to optimize the first defined function in attached code? I wonder if the exercise I've done can be optimized for readability and performance. The exercise was about determining if the ...
MrSigma123's user avatar
1 vote
4 answers
672 views

Function to sum the first and last item in an array until there's only two items left in the array

I've recently failed a coding challenge and I'd like to know the solution to the problem. Here's what was asked of me (from memory as I do not have access to the question anymore): Create a function ...
Laila Campos's user avatar
-4 votes
1 answer
158 views

Difference between -- , -= 1 and - 1

I have been working through some freeCodeCamp exercises and while working on a recursion problem in which all the numbers between a given range have to be added to an array (including both the numbers)...
Suryasish Paul's user avatar
2 votes
3 answers
167 views

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 presumably both) because from what I know I may need ...
Hhadi12's user avatar
  • 23
0 votes
4 answers
1k views

How to recursively map/restructure an object?

I would like an array of objects with all object keys from a nested object. I wrote a recursive function to do this however at the point that the function is recalled it is not going through the ...
coolps811's user avatar
  • 323
-2 votes
2 answers
670 views

Java -how can I store an array in switch case

I need to build code that first gets a 2d array and then prints it. for this, I built a menu with a switch case. when the user clicks 0, the user types the size of the array (the size is always n*n), ...
Swanky_Dwarf's user avatar
-1 votes
1 answer
206 views

PHP Recursive Function - How To Avoid Using A Global Variable

I have created a function that returns an array of data for the descendants of a chosen Parent. First it checks for Children of the Parent whose UUID we have fed to it, it then checks for further ...
DivFellaPoor's user avatar
0 votes
1 answer
48 views

function to make Tree like Array in to Array

I have $tree like array which made by function from the $array I need a function to make it $tree to $array back so I need a function to make it back. lets call it $list this time. I will share $tree ,...
codepnk's user avatar
  • 33
0 votes
1 answer
460 views

I have a task to write a recursive function to print all the numbers of an array whose indexes are prime numbers

I have a task to write a recursive function to print all the numbers of an array whose indexes are prime numbers. Actually, I can understand recursion, but I can't get in for void functions. This is ...
xxx's user avatar
  • 43
0 votes
1 answer
80 views

How to put the answer from recursive function in an array (PHP)?

there, I tried many time to put the answer from the recursive function inside an array ($result) but I couldn't. Here the code: function readDirs($path , $result = []) { $dirHandle = opendir($...
user avatar

15 30 50 per page
1
2 3 4 5
8