recursion

Recursion & MYSQL ?

I got a really simple table structure like this: Table Page Hits id | title | parent | hits --------------------------- 1 | Root | | 23 2 | Child | 1 | 20 3 | ChildX | 1 | 30 4 | GChild | 2 | 40 As I don't want to have the recursion in my code I would like to do a recurisive SQL. Is there any SELECT sta...

Get line number while using grep.

Hello I am using grep recursive to search files for a string, and all the matched files and the lines containing that string are print on the terminal. But is it possible to get the line numbers of those lines too?? ex: presently what I get is /var/www/file.php: $options = "this.target", but what I am trying to get is /var/www/file.php:...

Traverse tree without recursion and stack in C

How to traverse each node of a tree efficiently without recursion in C (no C++)? Suppose I have the following node structure of that tree: struct Node { struct Node* next; /* sibling node linked list */ struct Node* parent; /* parent of current node */ struct Node* child; /* first child node */ } It's not ho...

PHP - BBCode parser - recursive [quote] with regex and preg_replace

hello, i'm making my own bbcode parser, and i've a problem when i try to do the recursive quote. this is my code : function forumBBCode($str){ $format_search=array( '#\[quote=(.*?)\](.*?)\[/quote\]#is' ); $format_replace=array( '<blockquote class="quotearea"><i><a class="lblackbu" href="./index.php?status=userview&userv=$1">$1</a> wr...

How to optimize a recursive algorithm to not repeat itself?

After finding the difflib.SequenceMatcher class in Python's standard library to be unsuitable for my needs, a generic "diff"-ing module was written to solve a problem space. After having several months to think more about what it is doing, the recursive algorithm appears to be searching more than in needs to by re-searching the same area...

How can memoization be applied to this algorithm?

After finding the difflib.SequenceMatcher class in Python's standard library to be unsuitable for my needs, a generic "diff"-ing module was written to solve a problem space. After having several months to think more about what it is doing, the recursive algorithm appears to be searching more than in needs to by re-searching the same area...

jQuery custom events and too much recursion error in Firefox 3.6.6 and 4.0 beta 1

I am getting a "too much recursion" error. I will try to give a clear analog to my actual application where this problem is occurring. Imagine that the app is trying call a webservice to get information about the contents of a very long freight train. There is so much information that we cannot simply invoke the webservice and tell i...

Recursion in MIPS

I want implement a recursive program in assembly for MIPS, more specifically the well known Fibonacci function. There's the implementation in C: int fib(int n) { if(n<2) return 1; return fib(n-1)+fib(n-2); } ...

Recursive Set in OCaml

Hello, how can I manage to define a Set in OCaml that can contains element of its type too? To explain the problem I have a type declaration for a lot of data types like type value = Nil | Int of int | Float of float | Complex of Complex.t | String of string | Regexp of regexp | Char of char | Bool of bool | Range of (int*int) list |...

Recursive method in Java seems to just "goto" the first line of the method instead of actually go into the next call.

I am creating a factory that makes rooms, and it is passed an int of steps and a start room and it is supposed to do a step, build a room, and then call itself with one fewer step and the new room as the start room. The problem is that it never ends. In the debugger, I can see that it's calling itself, which creates another method call i...

Java solving a maze with recursion problem

I have an assignment where I am supposed to be able to display the path of a maze from the entrance to the exit and I have gotten it to work to a degree but when the maze gets more complicated with dead ends and such the program goes into infinite recursion. If you could give me any help to point me in the right direction it would be muc...

Ordering a WITH RECURSIVE query in Postgres

Hi, I'm executing a recursive query in Postgres to retrieve a list of emails and their threaded children as follows: WITH RECURSIVE cte (id, title, path, parent_id, depth) AS ( SELECT id, title, array[id] AS path, parent_id, 1 AS depth FROM emails WHERE parent_id IS NULL UNION A...

Create folders recursively in Delphi

Need some help in creating function which can create folders recursively with giving path: C:\TestFolder\Another\AndAnother Delphi function MkDir returning IOerror = 3. MkDir('C:\TestFolder\Another\AndAnother'); Thanks in advance ...

how can i get catch the root of a stackoverflow exception on recursive code

I have the following recursive code and i am getting a stackoverflow exception. I can't figure out the root cause because once i get the exception,i dont get the full call stack in Visual studio. The idea is that there are org teams that roll up into larger "Main" teams. Does anyone see a flaw on this code below that could be the culp...

How to `chmod -R +w` with Ant, files and folders?

I'd like to do the equivalent of a chmod -R +w foo/ in an Ant build script. So far I'm using this: <chmod perm="g+w"> <dirset dir="${basedir}/foo"> </dirset> <fileset dir="${basedir}/foo"> </fileset> </chmod> Is there a neater way to write that to include files and folders recursively? ...

Disable Check-boxes recursively in RAD tree view

I am trying to select all the check-boxes of the children in a Telerik RAD Tree view when the user checks a parent node and disable the check-boxes of all child nodes. I have a recursive function that is successfully checking the boxes, but i'm not having much luck in disabling all child check-boxes. Here is my code: <script type="t...

django: recursion using post-save signal

Here's the situation: Let's say I have a model A in django. When I'm saving an object (of class A) I need to save it's fields into all other objects of this class. I mean I need every other A object to be copy of lat saved one. When I use signals (post-save for example) I get a recursion (objects try to save each other I guess) and my...

mysql store procedure recusion not passing variable.

Hi I'm having problems getting this to work in mysql. DELIMITER $$ DROP PROCEDURE IF EXISTS `insert_v5tag_count` $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `insert_v5tag_count`(IN call_tag_id INT,IN rel_tag_id VARCHAR(100),IN inp_object_id VARCHAR(100),IN level_num VARCHAR(100)) BEGIN DECLARE done2 INT; DECLARE i_tag_id2 INT; DECLA...

Recursion AJAX post, Causing Computer to run slowly

I have this recursion loop where inside the function I have atleast 2 ajax get/post, and the recursion happens after the first ajax get. my function structure is like this, function Loop() { $.get(url, data, function(result) { for loop to render the result { // render the result here } for loop to...

HTML form data to recursive json dict

I would like to convert flat form data to recursive JSON data in python or javascript. This JSON data can later be interpreted by a template engine (google for tempest, it has django like syntax). There are plenty examples to convert flat data to recursive data, but the problem is it can't be a dict or list only. I tried to do it in man...