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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:24:26+00:00 2026-05-27T14:24:26+00:00

I have a algorithm which does bin packing based on certain conditions. I find

  • 0

I have a algorithm which does bin packing based on certain conditions. I find that the flow of the algorithm is little bit complex for the readers to understand.

Below you can find the developed Java code. Is there a much simplified alternative flow for this code?

void binpack() {
boolean set=false, cmap=false;
        while(set==false) {
            set=true;
            cmap=false;
            pack[k.cnt]=new bins(k.lim, k.ptim);
            for(int i=0;i<tot;i++) {           
                int s1,s2;
                if(jm[i][1]==0) {
                    s1=jm[i][0]; 
                    set=false;

                    else if(pack[k.cnt].pushk<k.lim) {
                        for(int j=0;j<pack[k.cnt].pushk;j++) {
                            s2=pack[k.cnt].binjm[j][0];
                            for (Iterator<Integer> g= list[s1].iterator(); g.hasNext();) {

    }
}

Notes:

ptim–>present time

etim–>end time

lim–>limit

  • 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-27T14:24:27+00:00Added an answer on May 27, 2026 at 2:24 pm

    A couple of things off the top of my head:

    1. Variable names should be more expressive. Don’t abbreviate, especially not to save one or two characters (e.g. ptim, chk())
    2. Put spaces after opening and before closing parentheses, after and before operators and so on. It sounds daft but you’ll be amazed how easier your code will be to read.
    3. Avoid unnecessary boolean comparisons (e.g. if ( bool == false ) should be if ( !bool )
    4. Avoid one-liner ifs or whiles, use proper {} blocks.
    5. Don’t pre-declare variables if you don’t have to.
    6. Instead of the double break structure you have in your nested loop, break to a label.
    7. And most of all: factor some of those loops out into methods.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an algorithm that generates strings based on a list of input words.
Problem: I have to design an algorithm, which does the following for me: Say
I have written an anagram solving algorithm, which does not work. for word in
I have a recursive algorithm which steps through a string, character by character, and
I have a small algorithm which replaces the position of characters in a String:
I have an algorithm that recursively makes change in the following manner: public static
I have this algorithm that I want to implement on VB6. Sub Main() dim
If I have an algorithm that takes n log n steps (e.g. heapsort), where
I have a two part question Best-Practice I have an algorithm that performs some
I have a site which does not have a DB in the back-end but

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.