I would like to ask you a question if you have a little bit of time. I have the following table:
I need to write a program that determines how many rows I have that start with 1, how many that start with 1,2 how many start with 1,2,3; 1,2,4;.....; 1,3,4;....; 2,2; 2,2,3 .... etc. etc. In other works I need to know all these possible combinations. I think this can be done iteratively with a bunch of for loops but it is a bit non-elegant. I have heard that recursive method is a little better. I have a book that talks about a simple recursive method (so I know what it is in theory) but I cannot get it to work on this table splitting. I guess I don't know whow to start. Do you think you would be able to help me to get going with this approach? Or maybe you'll convince me that recursive method is not the way to go.
I'd be hugely thankful to you! -Eric
I don't understand the question - I don't see the pattern in the prefix strings you want to count. You've listed the pattern, but what is the problem if the data were generic? I ask this because you can't define the prefixes to count giving an example.
I'm not sure a see an algorithm suited for recursion. Generally in programming, simple is more elegant than complicated.
The rule I use for recursion is, if I can apply an algorithm to part of the data, and then the same algorithm can be used for the rest, then it's a good choice to use. I've found over the many years of professional programming that recursion is quite rare.