Recursive Functions

How to use recursive functions to generate combinations?

Can you explain the scenario in detail.

user defined item lengths.we generate combinations(1,2,3,4 and 5 .max of 5) and we do some calculations to generate which combinations has lowest scrap.we done the for loops to generate feature the combinations are increase again we put one more for loop.this is very large and performance may my idea is to use recursive functions…

Hi Kishore,

Unless you show us an example with some data, we cannot suggest a solution. When submitting questions like these, please provide more details as what will be the inout and what is the expected output along with your algorithm.

Well I can answer the root of your question…recursion is not the way to go for speed. Do it with loops. Recursion will make it slower.

Hi Alex

where is your solution?

You said you want to use recursive functions to improve speed. That will only make it slower. Recursion is slow. That is the solution.

Your question doesn’t provide enough detail for anybody to answer it with code. It’s hard to understand what you are asking.

Hi alex,

To generate the 4 and 5 combinations on using 4 and 5 for loops each loop execute 14 times so it is taking more to reduce time and which way i follow ?

Are you trying to get speed or make it simpler?

Copy/Paste your code and I’ll see if I can help make it faster. Sometimes, there is just no better way. Sometimes there is.