[algogeeks] Re: need help

2006-02-06 Thread Terry
hektor wrote: > my datas are > > A X 3 ( there are three "A" ) > B X 5 > C X 2 > > i want to see all possible addition like > > A > A + A > A + A + A > A + B > A + A + B > A + A + A + B > A + B + C > ... > ... > ... > > how can i do that ? > > thanks /* Iterative soln This forms the basis for r

[algogeeks] Re: Arrange Matrices In Order

2006-02-06 Thread Prunthaban Kanthakumar
Sorry for the late reply. Let me post my solution (You need not know anything about Latin squares to understand this :) ) For N, let me consider a matrix where the first row and column are 1...N   1 2 3  ... N 2 3 . . N   Now we can fill the inner matrix using brute force...and find out the number

[algogeeks] Re: recursion question

2006-02-06 Thread Gene
Indeed the C/C++ compilers I've used lately don't eliminate tail recursion. GCC used to do it, but later versions don't seem to work. MS Visual C has never worked. On the other hand, all functional language compilers are similar in this respect to Scheme. They need to be since tail recursion is

[algogeeks] Re: recursion question

2006-02-06 Thread H.
This is interesting you say this (and very timely), because in a C++ data structures course I'm taking, we're creating recursive box trace diagrams. Even in tail-recursive functions, we draw it such that the stack keeps on growing. So I'm curious if we draw it this way because: 1. you can never c

[algogeeks] need help

2006-02-06 Thread hektor
my datas are A X 3 ( there are three "A" ) B X 5 C X 2 i want to see all possible addition like A A + A A + A + A A + B A + A + B A + A + A + B A + B + C ... ... ... how can i do that ? thanks

[algogeeks] Re: recursion question

2006-02-06 Thread Gene
There is a lot of work on this in the literature on functional languages, where rewriting recursions can lead to aymptotic speedups. Often the idea is to get from a general recursion to tail recursion in order to avoid stack growth and value copying.

[algogeeks] recursion question

2006-02-06 Thread H.
When writing a string backwards recursively, there are at least two ways to do it: in pseudocode: void writeBackward1 ( string s): if s is empty do nothing if s isn't empty output last character of s writeBackward1 ( s minus last character) void writeBackward2 (string s):