Hey!
Please let me know if this is bad practice or in someway a bad thing to do. The thing is in my program I need to make a method which goes through the root element and all child nodes of that element. My elements are like this:
|--ID--|--Parent--|--Additinal info--|
| 1 | 0 | root element |
| 2 | 0 | root ele...
This is a bank simulation that takes into account 20 different serving lines with a single queue, customers arrive following an exponential rate and they are served during a time that follows a normal probability distribution with mean 40 and standard deviation 20.
Things were working just fine till I decided to exclude the negative va...
I use Clearcase on a project with ~3700 files. While making a release, there are some directories that have to be labeled recursively. The file count here is ~2400. The files in other directories are selectively labelled. I currently label the files using a script to iterate through a list of files and label the files one by one. This ta...
This is not homework. I'm learning Standard ML on my own. I know a bit of Scheme, too, so this question ought to be answerable in either language.
My self-imposed assignment is to write a function that constructs a list of integers from 1 to n. For example, list(7) should return [1,2,3,4,5,6,7]. An O(n) solution would be ideal.
It's ea...
Consider the following simple DAG:
1->2->3->4
And a table, #bar, describing this (I'm using SQL Server 2005):
parent_id child_id
1 2
2 3
3 4
//... other edges, not connected to the subgraph above
Now imagine that I have some other arbitrary criteria that select the first and last edges, i.e. 1->2 a...
I was exploring another question, when I hit this behaviour in Sql Server 2005. This query would exhaust the maximum recursion:
with foo(parent_id,child_id) as (
select parent_id,child_id
from #bar where parent_id in (1,3)
union all
select #bar.* -- Line that changed
from #bar
join foo on #bar.parent_id = foo.ch...
I am currently working on a project for the iPhone that requires accessing a large amount of hierarchical data stored in a local sqlite database. One of the more common operations is calculating a rollup status field. Right now, I'm doing that by recursing through all the descendants of that item (which can be anywhere from 1 to n levels...
Hello,
I have several navigation related functions which I would like to have no depth limits. These generate CSS menus, breadcrumb trails and the like.
I am stumped as to how I would make the functions follow each path to depth or to root without explicit looping.
The following is a typical example where I want the topmost parent of...
I have a table in a database which has category data:
id title parent
1 category 1 0
2 category 2 2
3 category 3 3
4 category 4 0
Eeach parent may have the parent row id.
For example, category 3 is a child of category 2, which is child of category 1.
category 1
category 2
category 3
category 4
...
I want to go through all the elements on a page using Javascript and see if they have a property set. Is there an easy way to do this, or do I have to use a recursive solution?
...
Bear with me if this is unclear; I have trouble fully wrapping my head around this (hence why I am here to ask for help).
I have an array that looks like this:
Array
(
[DimA1] => Array
(
[DimB1] => Array
(
[DimC1] => Array
(
[value1] => 13708
...
I'm working on a board game algorithm where a large tree is traversed using recursion, however, it's not behaving as expected. How do I handle this and what are you experiences with these situations?
To make things worse, it's using alpha-beta pruning which means entire parts of the tree are never visited, as well that it simply stops r...
Hey all, I was working on a recursive generator to create the fixed integer partitions of a number and I was confused by a scoping issue.
The code is similar to this snippet.
def testGen(a,n):
if n <= 1:
print('yield', a)
yield a
else:
for i in range(2):
a[i] += n
for j in testGen...
The recursion is sort of a 'divide and conquer' style, it splits up while getting smaller (Tree data structure), and I want it to break completely if a violation is found, meaning break all the recursive paths, and return true. Is this possible?
...
Hi, I have been messing around with recursion today. Often a programming technique that is not used enough.
So.. I set myself the task to recursively reverse a string, heres what I came up with :
//A method to reverse a string using recursion
public String reverseString(String s){
char c = s.charAt(s.length()-1);
if...
Can someone explain mathematical induction to prove a recursive method? I am a freshmen computer science student and I have not yet taken Calculus (I have had up through Trig). I kind of understand it but I have trouble when asked to write out an induction proof for a recursive method.
...
I'm trying to write a recursive fun in an Erlang shell, but I keep getting an unbound variable exception:
1> Foo = fun(X) -> Foo(X) end.
* 1: variable 'Foo' is unbound
This probably goes without saying, but I'm not trying to create an infinite loop! This is just a simple example of the error I'm getting.
...
What is the theoretical/practical limit to the recursion depth in languages implementing Tail Call optimisation? (Please assume that the recurring function is properly tail call-ed).
My guess is that the theoretical limit is NONE, as there is no recursive process, even though it is recursive procedure. Practical limit would be that allo...
I have a table of dates call [BadDates], it has just one column where every record is a date to exclude. I have a UDF as follows:
CREATE FUNCTION [dbo].[udf_GetDateInBusinessDays]
(
@StartDate datetime, --Start Date
@NumberDays int --Good days ahead
)
RETURNS datetime
AS
BEGIN
-- Declare the return variable here
DECLARE ...
I want to execute some Python code, typed at runtime, so I get the string and call
exec(pp, globals(), locals())
where pp is the string. It works fine, except for recursive calls, e. g., for example, this code is OK:
def horse():
robot.step()
robot.step()
robot.turn(-1)
robot.step()
while True:
horse()
But t...