Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8772479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:02:34+00:00 2026-06-13T18:02:34+00:00

I’m unsure how to distribute a recursive program. Right now its recursive and runs

  • 0

I’m unsure how to distribute a recursive program. Right now its recursive and runs as a single program but my goal is distribute this program to other machines who only generate a subset of the data.

Here’s background on the program. I give it a target (in this case 10) and a list of items with min/max weights and it returns the combinations of each.

So with 3 items, and

Low = 2, 2, 2
high = 6, 6, 6
Target = 10

The result is:

2 2 4
2 3 3
2 4 2
3 2 3
3 3 2
4 2 2

Here is the method that does the work:

void distribute (int i, int [] low, int [] high, final int rest, int [] sizes) {
    // System.out.println (i + " " + rest + " " + sizes);
    if (i == sizes.length - 1) {
        if (rest < high [i]) {
            sizes[i] = rest;
            result.add (Arrays.copyOf (sizes, sizes.length));
        }
    }
    else
        for (int c = 0;
             c <= java.lang.Math.min (high [i] - low [i], rest);
             ++c) {
            sizes [i] = c;
            distribute (i + 1, low, high, rest - c, sizes);
        }
}

I’m wondering if anyone has any ideas of how to distribute the output so, in the example above, if I have 3 servers each server only generates 2 unique entries instead of having to generate the entire thing. Say, in advance I know there will be 6 results and want 2 to be distributed to each machine how can I do that. Is it possible and if so what’s the logic?

If it helps, here’s the entire program: http://pastebin.com/RikqPgKh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:02:36+00:00Added an answer on June 13, 2026 at 6:02 pm

    I figure you want to run the algorithm on several machines and then unite the results. You just have to split the execution. This should not be too hard as the parameters already limit the results.

    For instance, instead of L:[2,2,2] H:[6,6,6] execute

    L:[2,2,2] H:[3,6,6]
    L:[4,2,2] H:[5,6,6]
    L:[6,2,2] H:[6,6,6]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

unsure how to go about describing this but here i go: For some reason,
I'm really unsure if this is even possible but we have an issue where
Unsure if this is the right place to ask such question. I have to
I am unsure what to tag this under, but I'd imagine it's a question
Unsure if I've phrased this correctly, but in the callback how do I reference
I am unsure if this is even possible, but I thought I would ask.
I'm a little unsure how to word the title to this question but I'm
Unsure why I am recieving this error as converting other columns has worked fine.
I am unsure how to ask this, but I will give it my best
I was unsure whether to ask here or in superuser, but this site seemed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.