6
votes
3answers
56 views

How are variables stored in memory in recursion?

I'm unsure about how variables are created and stored in memory during recursion. Below is an example taken from C Primer Plus: #include <stdio.h> void recursiontest(int); int main(){ ...
1
vote
0answers
13 views

Implementing an algorithm that walks the DOM without recursion [migrated]

Here's a simple algorithm that walks the DOM given a node: function walkDOM(n) { do { console.log(n); if (n.hasChildNodes()) { walkDOM(n.firstChild) } } ...
0
votes
1answer
52 views

jquery/javascript error - too much recursion - with self-calling function

I have a small problem with a function that calls itself from within itself. The following function pretty much works, as can be seen here ... http://jsfiddle.net/justinayles/frPZ8/2/ but if you ...
-1
votes
3answers
93 views

Delphi Recursive function replace string

I tried replace found text recursively but i cant get it working. This will replace only 1 ´a´ char before each ´text´ but i want replace all ´a´ characters before text //Declared recursive function ...
1
vote
3answers
49 views

Recursive function with return value VS using OUT parameter

Just a quick question, What do you think is better of the two: - A recursive function that returns a value - A recursive function with an OUT paremeter (which will serve as a return value.) I ...
4
votes
2answers
136 views

C++ - Calling a function inside the same function's definition

I was writing something similar to the code below and I accidentally called the same function inside the body of the function definition. double function(double &value) { //do something with ...
0
votes
2answers
60 views

Different outputs from recursive functions

I just found out about recursive functions about a few minutes back. I was playing around with them and now I am getting different outputs from the following functions: int function(int m) { m ...
0
votes
3answers
40 views

Function to return a table of all children of a node

Let's say I've got the following table structure: | ID | ParentID | Name | I'd like to write a recursive PostgreSQL function for getting all child nodes of a node ID passed to it as a parameter. ...
0
votes
4answers
86 views

Are there any practical applications for recursion [closed]

Are there any practical applications to recursion, because the only examples ive ever seen relating to recursion out factorials and can be easily written using a standard loop instead of calling the ...
0
votes
3answers
76 views

Why are these functions recurring?

If I execute step 1 of the below function twice (each of which in turn triggers steps 2,3,6), I want to then be able to execute step 4 once without it recurring the same number of times that I ...
1
vote
1answer
86 views

Recursive function call python [closed]

I am a Physics intern at TCD. My summer project is to write a Python code that searches, in a random packing, for "ratthers" i.e. particles that have a number of contacts with other particles at most ...
-1
votes
0answers
37 views

Can we create recursive functions only by using if-else statements? [migrated]

I have to show if a program containing only if-else statements is able to calculate the following type of functions: [f(x)]^n. The function f is applied n times on x, so I guess this is a recursive ...
-4
votes
1answer
52 views

Recursive function that divides the number by 2 without using / [closed]

I need help. I need to create a recursive function that receives a "n" number and returns "n/2" without dividing. Edit : This is what I wrote, but it works only if after dividing it will still be a ...
0
votes
0answers
36 views

Adding function handles in MATLAB

I am doing a molecular dynamics Finite Element Simulation for crack/impurities in materials. I tried this simpler code which works on command window : k = [1,2,3,4,5]; c = [1,2,3,4,5]; F{2} = @(x,y) ...
-2
votes
2answers
107 views

Is this recursion?

I've read this code from Stanford's CS106B class's textbook in the recursion chapter. This recursive function uses loop. Although decomposition happens between recursive calls and the loop merely ...

1 2 3 4 5 15
15 30 50 per page