My MySQL looks like this: (the name of the table is category)
'id', 'content', 'parent'
where:
id = the id of the category
content =
some-text-we-dont-care-about
parent = the id of the parent
category
this is what I'm trying right now:
function remrecurs($id) {
$qlist=mysql_query("SELECT * FROM category WHERE parent='$id'");
...
In many functional languages using a recursion is considered to be a good practice. I think it is good because of the way compiler optimizes functional language's code.
But is it a good practice to use recursion in C#, when creating an algorithm? Is it right to say in regards to C#, that recursive algorithms will result in your stack g...
public void question(int col, int n, Node<Integer> part_soln) {
if (col==0) stack.push(part_soln);
else for (int row=1; row<=n; row++)
{ if (!exists(row,part_soln) && !unsafe(col,row,col+1,part_soln))
{ Node<Integer> new_soln = new Node<Integer>(row,part_soln);
questi...
I wanted to provide unique ID for different categories of models in my db. So I've introduced a dummy model :
class GUUID(models.Model):
guuid = models.PositiveSmallIntegerField(_(u"Dummy GUUID"), default=1)
and in model that I want to have unique ID:
class Event(models.Model):
unique = models.IntegerField(blank=False, edita...
Hi,
Is there any alternative way to recursion? The classs i am dealing are as follows
TibrvMsg This is message class which contains fields of type TirvMsgField
TibrvMsg can also contain TirvMsgField of type TibrvMsg.That means message can contain fields which are message themselves.
I can use recursion to print all the fields.But i want ...
Hello everyone,
i have recently run into a strange problem. i have a table in db named Task. A Task may have a parent task and more than one child tasks (self join). i have written a stored procedure that returns me all the tasks in the project their children and sub children upto n level using CTE (common table expression). my required...
i have a table which contains the following fields
•Supervisorid •Empid This is just like a referral program. A guy can refer 3 guys under him i.e, 3 is referring three guys namely 4 5 8 similarly 4 is referring 9 10 and 11 likewise 8 is referring 12, 13 it goes like this..
I want a query to get all EmpId under Supervisor 3
...
I'm trying to build a navigation menu. I am receiving an array with a structure like this:
[
[
Title = A
Sub items = [
Title = B
Sub items = [
Title = C
]
]
],
[
Title = A
Sub items = [
Title = B
Sub items = [
Title = D
]
]
],
]
I need to take it and ...
Heres a snippet:
translate("a", "4").
translate("m", "/\\/\\").
tol33t([], []).
tol33t([Upper|UpperTail], [Lower|LowerTail]) :-
translate([Upper], [Lower]),
tol33t(UpperTail, LowerTail).
Basically what i want to do is look up in the table for a letter and then get that letter and add it to the new list.
What i have works if ...
I wanted to know how to apply flood fill on array , my array is two dimensional , which contains times new roman font type letter boundry.
The boundry line contains 1's and inside and outside all 0's.
I want to fill all 1's instead 0 in only inside.
But i need a logic which do not required more memory.
So avoid recursion and stack or que...
I'm trying to create something similar to a for-loop with the recursive idiom I've seen across the web. My implementation is with a parameter that tells what to print. I use the Eclipse built-in XSL transformator and I can't for the life of me see why it gives a StackOverflowException:
<!--
Loops recursively to print something the ...
private static int reverse(int n, int r) {
if (n == 0) return r;
return reverse(n/10, 10*r+n%10);
}
public static int reverse(int n) {
return reverse(n, 0);
}
I've tested this and it works, I just cannot figure out how. I know that the number is divided by ten and then goes into the loop again, but it seem as if until n becomes a ...
I was just wondering whether if it was possible to replace recursion with an explicit stack when you need the return value(s) and are comparing them to find the best solution (like dynamic programming)? So something like (it doesn't do anything, just an example):
int resursiveFunction (int state) {
if (known[state]) return cache[s...
Hello,
MY database looks like (pligg cms, sample data)
id catID parentID catName
1 1 0 location
2 2 0 color
3 3 1 USA
4 4 3 Illinois
5 5 3 Chicago
6 6 2 Black
7 7 2 Red
Let say, how do i get top parentID of chicago, it should b...
Possible Duplicate:
Is recursion ever faster than looping?
I was first trained to program seriously in C, about 15 years ago. My employer wanted highly optimized code for computationally difficult tasks. I remember being advised more than once to rewrite recursions as loops, even at the expensive of readability, in order to ...
So , i still don't completely understand how lists and recursion work in prolog, could be why i am having trouble with this, but i don't even know how to begin this problem.
There is a list of friends.
f(a,b).
f(a,c).
f(a,d).
f(b,c).
f(b,e).
f(b,f).
f(c,e).
f(c,g).
f(g,e).
etc..
I have to find if someone is a friend through someone e...
Is jquery 1.3.2 conflicting with jqueryui 1.8.4? I get the error "Too much recursion" (using the code below).
When I combine jquery 1.3.2 with jqueryui 1.7.2 I don't get this error, but it breaks my code...
Is there somewhere a reference table which jquery version works with which jqueryui code?
<html>
<head>
<title>This is the title<...
this code:
$(document).ready(function() {
$('body').click(function(evt) {
if(evt.target.nodeName === 'A' && $(evt.target).hasClass('cross-link'))
{
$('a[href=#2]').trigger('click');
} });});
given me and error of "too much recursion"
one might think that I should just attach a handler to the crosslink e...
Hi,
I have a ArrayObject structure that is quite complex to output, it can/and consists of multiple levels of relationship e.g. Parent -> Child -> Children -> Child etc.
Structures like this are quite complex to work with when using a foreach, for or while loop. I've looked into SPL Iterators and I think this can be used. I'm a bit unf...
hello!
how can i check a array recursively of empty content like this example
Array
(
[product_data] => Array
(
[0] => Array
(
[title] =>
[description] =>
[price] =>
)
)
[product_data] => Array
(
...