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
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
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
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
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
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.
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):