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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:55:36+00:00 2026-05-31T21:55:36+00:00

I am trying to configure out a method for checking conflicts between the head

  • 0

I am trying to configure out a method for checking conflicts between the head and all of the other nodes. At this point, I’m getting stuck in a loop. Any idea how to loop through the list, comparing head with head.next .next .next.next and so on?

EDIT: After adding a return false; after the conflictCheck(a,b.getNext()), there is no longer the loop problem but the output reflects this method NOT comparing each node with the head node.

EDIT X 2! : I believe I have the loop checking for conflicts working fine thanks to everyone who commented/answered. Now I have strange results in my program,where conflicts are being detected but nothing is being done about them. I’ve added my other important method that deals with these shenanigans. Also, my output is below. Is there any reason why Every node’s column is moving to either 3, or staying at 1???

    public static void playChess() {
    System.out.println("Playing chess");
    if (conflictCheck(head, head.getNext())) {
        if (head.getColumn() == 8) {
            queens.pop();
        }
        else if (!queens.isEmpty() && head.getColumn()!= 8) {
            System.out.println("Adjusting head");
            head.setColumn(head.getColumn()+1);
            System.out.println("Head is now " + head.getRow() + ", " + head.getColumn());
            playChess();

        }
    }

    else if (queens.size() < 8) {
        System.out.println("Stack isn't full yet");
        queens.push(queens.size()+1,1);
        queens.viewPieces();
        playChess();
        }
    else {
        success= true;
        System.out.println("Success");
        queens.viewPieces();
        return;
    }
}


    public static boolean conflictCheck(QueenNode a, QueenNode b) {
    //checks for conflicts between head and all other nodes in the stack
    a= head;
    while (b != null) {
        if (a.getRow()!=b.getRow() && a.getColumn()!=b.getColumn() && !diagonal(a,b)){
            conflictCheck(a,b.getNext());
        }
        else {
            System.out.println("There is a conflict");
            return true;
        }
    }
    return false;
}

My output

Playing chess
Comparing 8 ,3 And 7 , 1
There is a conflict with 8,3 And 6,3
Success
The stack
8, 3
7, 1
6, 3
5, 1
4, 3
3, 1
2, 3
1, 1
End of stack

  • 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-31T21:55:37+00:00Added an answer on May 31, 2026 at 9:55 pm

    You’re mixing the cycle with the recursive call.

    If I understand you correctly, you would want something like:

    public static boolean conflictCheck(QueenNode a, QueenNode b) {
    //checks for conflicts between head and all other nodes in the stack
    
        if (b == null){
            return false;
        }
        if (a.getRow()!=b.getRow() && a.getColumn()!=b.getColumn() && !diagonal(a,b)){
            return conflictCheck(a,b.getNext());
        }
        else {
            System.out.println("There is a conflict");
            return true;
        }
    }
    

    I didn’t run the code, so I’m hoping you get the picture, there’s probably a syntax error or 4.

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

Sidebar

Related Questions

I am trying to work out how to configure PHPUnit to use the test
I'm trying to figure out how to configure a tool to run whenever a
Hello i'm trying to configure apache2 server for python, i used this command to
I have been trying for hours to figure this out. I have some JSON
Am trying to configure a two component picker, and am getting some errors which
I find my self out of ideas trying to get this app to work.
I'm trying to configure SSL on EC2onrails with no luck. At present I am
I am trying to configure the NCommon NHRepository in my project with Structure Map.
I'm trying to configure a parameterized query to the effect of: SELECT field1 FROM
I'm trying to configure a class with Annotation based configuration in Spring 3, which

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.