Hello, for a University assignment I am attempting to use a brute force search to generate all possible combinations of a list of numbers. This is only a small part of what I must do. I realise that a Brute Force Search would be extremely computationally expensive but it is required for my research. I can't think how one would go about beginning to generate all possible permutations. The only idea I can come up with would be calling a recursive function on a list that continually breaks it down but I cannot think of how to even begin implementing this. Can anyone give me a starting point or the general well explained pseudocode on how this would be done.

Thanks,
Jonathon.

Recommended Answers

All 4 Replies

Hello,
do you knew java to help me.

Hello,
do you knew java to help me.

yes... Java is a brand of coffee.
If you want help with your coding, start a new thread, provide us with the info:
- what does it need to do
- what have you allready done
- where are you stuck
and all additional info you think you need to share with us.
also, do not forget to show your code (formatted, if possible)

There are several forms of a recursive function, here are some :

recurveFunc(<param>) {
     <type> result;

     if (<terminate condition>) {
          return <value_returned_when_the_function_ends>;
     }
     else {
         result =  recurveFunc(<param>-1);
    }

     return result;
}
recurveFunc(<param>) {
     <type> result;

     for(int i = 0; i < <param>; i++) {
          result =  recurveFunc(<param>-1);
     }

     return result;
}

for your problem, I think second form would work, but of coure you might want to replace the FOR loop wih WHILE or DO..WHILE.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.