I have several queries which use a WITH clause, or Common Table Expression, with a UNION ALL statement to recur through a table with a tree like structure in SQL server as described here. Would I see a difference in performance if I were to CREATE that same VIEW instead of including it with the WITH clause and having it generated every ...
I'm creating a tree-structure of categories with parentid's which can be called from children in such a way:
ID | Name | ParentID
1 1 0
2 2 1
3 3 2
4 4 1
Resulting in this:
1 = 1
2 = 1 -> 2
3 = 1 -> 2 -> 3
4 = 1 -> 4
which means 3 is a child of 2, which is a child of 1.
when trying to get this idea ...
I've developped a DLL for a driver in C. I wrote a test program in C++ and the DLL works fine.
Now I'd like to interract with this DLL using Python. I've successfully hidden most of the user defined C structures but there is one point where I have to use C structures. I'm rather new to python so I may get things wrong.
My approach is t...
Hi Guys and Girls,
I have a SQL 05 Stored Procedure that brings back around 180 rows with the structure:
ID | Name | ParentId.
What I would like to do is create a Treeview based on the records returned.
Below is a sample I adapted from elsewhere on the forum (here)
I nearly have it doing what I want but not quite.
This is the proble...
I have a tree structure
A -> B -> D -> Y
-> C -> X
-> X
I want to do an operation on all objects of class X, or all the children objects of class D (for example). I want to call start this operation from any node in the tree (ie recursively).
For e.g,
A.SetupDecorators();
(although I'm open to suggestions)
All classes i...
Steve Yegge mentioned it in a blog post and I have no idea what it means, could someone fill me in?
Is it the same thing as tail call optimization?
...
Hello,
I need to write a quick makefile for building all my projects. This is C++ code and I am using gmake.
Say I have a list of directories, I want to cd to each, issue gmake command and if it succeeds, go to the next one and so on.
I cooked this by looking at the gmake manual
.PHONY: all clean dirs $(DIRS)
dirs: $(DIRS)
$(DIRS):...
Working in python I want to extract a dataset with the following structure:
Each item has a unique ID and the unique ID of its parent. Each parent can have one or more children, each of which can have one or more children of its own, to n levels i.e. the data has an upturned tree-like structure. While it has the potential to go on for i...
I'm having a tough time in understanding the following code based on recursion algorithm in Java. I don't understand, what's the different value x and y have when they call within one another? I tried to get the right value by calling System.out.print() within a code, but still get no help.
public class RecursionExample
{
private ...
I have a matrix class with the size determined by template parameters.
template <unsigned cRows, unsigned cCols>
class Matrix {
...
};
My program uses matrices of a few sizes, typically 2x2, 3x3, and 4x4. By setting the matrix size with template parameters rather than run-time parameters allows the compiler to do a lot of inlinin...
Inspired by this question:
Is explicit type recursion possible in F#?
type 'a Mu = In of 'a Mu 'a
let unIn (In x) = x
This code unfortunatly gives "Type parameter cannot be used as type constructor.
Remarks: This construct is used in the paper Functional Programming with Overloading and Higher-Order Polymorphism, for example.
Exam...
Assuming the following model:
class Category(models.Model):
related = models.ManyToManyField('self', symmetrical = False, through = 'CategoryRelation', null = True, blank = True)
Assuming the following intermediate 'through' relation:
class CategoryRelation(models.Model):
source = models.ForeignKey('Category', null = False, b...
I have a recursive relationship between models:
Test
--> Questions
-------> (has_one) Remediation
------------> (has_many) Remediation_Questions
-----------------> (has_one) Question
Basically the idea is each question has a remediation (some link or block of text) associated with it. Each Remediation then has a set of remediation que...
I have a csv file with userid and manager fields.
How can I list all userids that report to a specific manager and its direct reports, drilled down to the last user.
Need a quick vbscript.
Thanks.
...
Hi, I'm in PHP working on an Euler problem. I have this function so far:
<?php
$biggest = 0;
$counter = 1;
function test($i){
global $biggest;
global $counter;
if ($i == 1) {
echo "I'm done! Took me $biggest steps";
}
else {
if ($i%2 == 0) {
$counter = $counter + 1;
if ($counter>$biggest) {
...
Hi Friends,
I am trying to write a method to calculate the sum of the odd numbers in all the numbers less than the given number. so eg. CalcOdd(7) would return 5 + 3 + 1 = 9. CalcOdd (10) would return 9 + 7 + 5 + 3 + 1 = 25 etc
The method needs to take in a number, subtract 1, then recursively work backwards adding all odd numbers unti...
I have the following need (in python):
generate all possible tuples of length 12 (could be more) containing either 0, 1 or 2 (basically, a ternary number with 12 digits)
filter these tuples according to specific criteria, culling those not good, and keeping the ones I need.
As I had to deal with small lengths until now, the function...
When recursing with Lists in Java, I frequently end up allocating and copying lists many many times. For example, I want to generate a List<List<Integer>> of all possible Integer sequences where:
Every number is between 1 and 9
Every number is greater or equal to the number before it
A number can appear between 0 and 3 times in a row.
...
I am struck in a small recursive code. I have printed output and it prints fine but when I try to put a counter to actually count my answers, it gives me scooping errors.
total = 0
def foo(me, t):
if t<0:
return
if t==0:
total = total+1
return
for i in range(1, me+1):
total = total+1
return foo(i, t-...
Hey There!
I use Xcode to code for a current iPhone Project. It's the first time i work with XCode. What i wonder is, whether i need to set somewhere how 'deep' i can be able to recursively look into the variables in the debugger.
If i have the debugger open, i can see all the current variables and open them. I can see all the fields o...