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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:24:12+00:00 2026-05-31T23:24:12+00:00

Had a problem with the recursive conflictCheck() method. That seems fine now. I have

  • 0

Had a problem with the recursive conflictCheck() method. That seems fine now. I have print lines for testing, that look good. Now, when something is a conflict (returns true), my playChess() method is supposed to fix the conflict by adjusting the node’s second variable, and so on.

My result is literally:

1,1

2,3

3,1

4,3

5,1
…

Even though the output says “oh we have a conflict” it doesn’t act on it once it reaches x,3

    public static boolean conflictCheck(QueenNode a, QueenNode b) {
    //checks for conflicts between head and all other nodes in the stack
    if (b == null) {
        System.out.println("Attempting Conflict Check: Nothing to Compare to");
        return false;
    }

    if (a.getRow()!=b.getRow() && a.getColumn()!=b.getColumn() && !diagonal(a,b)){
        System.out.println("Comparing " + a.getRow() + " ," + a.getColumn() +
                                    " And " + b.getRow() + " , " + b.getColumn());
        conflictCheck(a,b.getNext());
    }
    else {
        System.out.println("There is a conflict with " +a.getRow() + "," + a.getColumn()
                            + " And " + b.getRow() + "," + b.getColumn());
        return true;
        }
    return false;
}


    public static void playChess() {
    System.out.println("Playing chess");
    //Either there is a conflict between head and another node, the stack isn't full, or we have solution
    if (conflictCheck(head, head.getNext())) {
        if (head.getColumn() == 8) {
            queens.pop();
        }
        else if (!queens.isEmpty()) {
            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;
    }
}

The entire output:

The stack
1, 1
End of stack
Playing chess
Attempting Conflict Check: Nothing to Compare to
Stack isn't full yet
The stack
2, 1
1, 1
End of stack
Playing chess
There is a conflict with 2,1 And 1,1
Adjusting head
Head is now 2, 2
Playing chess
problem
There is a conflict with 2,2 And 1,1
Adjusting head
Head is now 2, 3
Playing chess
Comparing 2 ,3 And 1 , 1
Attempting Conflict Check: Nothing to Compare to
Stack isn't full yet
The stack
3, 1
2, 3
1, 1
End of stack
Playing chess
Comparing 3 ,1 And 2 , 3
There is a conflict with 3,1 And 1,1
Stack isn't full yet
The stack
4, 1
3, 1
2, 3
1, 1
End of stack
Playing chess
There is a conflict with 4,1 And 3,1
Adjusting head
Head is now 4, 2
Playing chess
problem
There is a conflict with 4,2 And 3,1
Adjusting head
Head is now 4, 3
Playing chess
Comparing 4 ,3 And 3 , 1
There is a conflict with 4,3 And 2,3
Stack isn't full yet
The stack
5, 1
4, 3
3, 1
2, 3
1, 1
End of stack
Playing chess
Comparing 5 ,1 And 4 , 3
There is a conflict with 5,1 And 3,1
Stack isn't full yet
The stack
6, 1
5, 1
4, 3
3, 1
2, 3
1, 1
End of stack
Playing chess
There is a conflict with 6,1 And 5,1
Adjusting head
Head is now 6, 2
Playing chess
problem
There is a conflict with 6,2 And 5,1
Adjusting head
Head is now 6, 3
Playing chess
Comparing 6 ,3 And 5 , 1
There is a conflict with 6,3 And 4,3
Stack isn't full yet
The stack
7, 1
6, 3
5, 1
4, 3
3, 1
2, 3
1, 1
End of stack
Playing chess
Comparing 7 ,1 And 6 , 3
There is a conflict with 7,1 And 5,1
Stack isn't full yet
The stack
8, 1
7, 1
6, 3
5, 1
4, 3
3, 1
2, 3
1, 1
End of stack
Playing chess
There is a conflict with 8,1 And 7,1
Adjusting head
Head is now 8, 2
Playing chess
problem
There is a conflict with 8,2 And 7,1
Adjusting head
Head is now 8, 3
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-31T23:24:13+00:00Added an answer on May 31, 2026 at 11:24 pm

    Since this is homework, there’s a small hint:

    The reason that you do not act on a conflict that you detect is most likely because you ignore the return value of conflictCheck(a,b.getNext()); that you call recursively from boolean conflictCheck(QueenNode a, QueenNode b).

    The problem of eight queens is explored in depth in this excellent work by E.W.Dijkstra on page 72. It’s coded in ALGOL-60 (which become obsolete even before my time), but the ideas are language-agnostic.

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

Sidebar

Related Questions

I got problem with core data, I had a table that exactly look like
I had a problem that was partially solved. To explain it quickly : I
The problem is that i need to write a recursive algorithm for reversing a
I have a recursive method call. When any exception is thrown, I would like
I have a recursive template definition (I just made up that term). I think
we had a heated discussion about a method name. We have a class User
I had posted another question earlier about deployment with Passenger. That problem turned out
I had a problem with committing changes after merging two branches of my project
I had this problem before and can't for life of me remember how to
I had no problem at all running the following code on a local server,

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.