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 1102785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:14:23+00:00 2026-05-17T01:14:23+00:00

How to, Sequentially distribute data from a list to arrays (or some other structure)

  • 0

How to, Sequentially distribute data from a list to arrays (or some other structure) of fixed size/weight.

For example, lets say I have a list of 10 elements. I want to sequentially distribute the elements to 3 arrays A, B, and C. The arrays are given a weight lets say A=3, B=5, and C=2.

The element would be distributed in the following fashion.

A - list[0]  list[3] list[6]
B - list[1]  list[4] list[7] list[8] list[9]
C - list[2]  list[5] 

If the size of the list was 13, then after the above distribution, it would start again after the cycle completes

A - list[0]  list[3] list[6] list[10]
B - list[1]  list[4] list[7] list[8] list[9] list[11]
C - list[2]  list[5] list[12]

The size of the list is dynamic, so in the above example, the list size would be 3, 4, or 100, etc. And the number of arrays (or structure) and weight of the arrays are available in runtime only.

Is there a good way to solve it?

  • 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-05-17T01:14:24+00:00Added an answer on May 17, 2026 at 1:14 am

    The easiest way to sequentially distribute element across different different weighted array (fixed size) array is to auto pollulate the stacks using array size. And put the stack in a circular array. sequentially get the next stack and pop the element of the stack. If stack has not more element remove it from the circular array until the distribution list is empty. if distribution list size is not predefined, or if circular array becomes empty, reset the circular array, and start from the beginning.

    A=3, B=5, and C=1.

        Stack<String> sA= new Stack<String>();
        sA.push("A");sA.push("A");sA.push("A");
    
        Stack<String> sB = new Stack<String>();
        sB .push("B");sB .push("B");sB .push("B");sB .push("B");sB .push("B");
    
    
        Stack<String> sC = new Stack<String>();
        sC.push("C");
    

    //add stack to array
    CircularLinkedList list = new CircularLinkedList();
    list.add(s1);
    list.add(s2);
    list.add(s3);

        CircularListIterator<Stack> iterator = list.iterator();
        Stack<String> s;
    

    //iterate till the stack is empty, reset the stack if distribution list is remaining
    // or if the lead comes from another source for example website, simply get the next stack

        while (iterator.hasNext()){
            s = iterator.next();
            if (s.empty()){
                iterator.remove();
                continue;
            } 
            System.out.println(s.pop());            
        }
    

    Here is an example of circular list //http://www.cs.princeton.edu/algs4/13stacks/CircularLinkedList.java.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that arrays in C are just pointers to sequentially stored data. But
Can you create a list of functions and then execute them sequentially, perhaps passing
I want to be able to compare one string to all other strings sequentially
I am making web page that will sequentially plays video from server on big
I have some calls that must execute sequentially. Consider an IService that has a
I have a large list of instructions that I need executed sequentially but slowly.
When you want to iterate sequentially over a list of numbers you will write:
I am using EmguCV to query frames sequentially from a capture that I defined
i am using a ThreadPoolExecutor with a thread pool size of one to sequentially
I am using selenium RC to cycle through a long list of URLs, sequentially

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.