Homework Help Global logo
  • Home
  • Coursework Help
  • Dissertation Help
  • Homework Help
  • My account
  • Order now
Order Now
Uncategorized

Solving the n-queens puzzle with backtracking

2 min read
Posted on 
March 8th, 2022
Home Uncategorized Solving the n-queens puzzle with backtracking
Learning Goal: I’m working on a python writing question and need an explanation and answer to help me learn.

You are given the code for solving the n-queens puzzle with backtracking. The program returns a single solution if there exists one. There may be multiple solutions, but we are NOT interested in all of them for this assignment.

You will notice that the existing implementation is not very efficient. When you test the code for n around 15 – 20, you will especially notice the drop in runtime.

Your task is to improve the algorithm so that the program runs more efficiently. First, examine the nQueens.py code carefully. Then implement in the required methods as follows:

  1. (30 pts) Fill in the body of the iselect_next_variable_improved method so that it implements minimum-remaining-values (MRV) heuristic. Replace this with select_next_variable. You will see that your code is more efficient now. You should use select_next_variable for the following parts.
  2. (10 pts) Fill in the body of backtrack_improved so that it implements the full backtracking algorithm with inference. Note that this method requires parts (c) or (d) to work efficiently.
  3. (30 pts) Fill in the body of forward_checking to implement the forward checking algorithm. You should be able to pass the forward_checking method as a parameter to backtrack_improved.
  4. (30 pts) Fill in the body of the ac3 method to implement the constraint propagation (“maintaining arc consistency”) algorithm. You should be able to pass the ac3 method as a parameter to backtrack_improved.

Notes:

– You may implement additional helper methods.

– You can use the backtrack_counter value to track the efficiency of your algorithms.

– Please refer to your textbook or the slides for constraint satisfaction (lectures 9-10) for the implementation of these algorithms.

– Please submit your code, including comments that explain your approach, by uploading a .py file to Blackboard.

– You can submit as many times as you like. Only the latest version will be evaluated.

attachment_1

Order an Essay Now & Get These Features For Free:

Turnitin Report

Formatting

Title Page

Citation

Outline

Place an Order
Share
Tweet
Share
Tweet
Calculate the price
Pages (275 words)
$0.00
Homework Help Global
Company
  • Coursework Help
  • Law Homework Help
  • Business Paper Help
  • Thesis Writing Help
Legal
  • Dissertation Help
  • Homework Help
  • Essay Writing
  • Custom Writing
How Our Service is Used:
Homework Help Global essays are NOT intended to be forwarded as finalized work as it is only strictly meant to be used for research and study purposes. Homework Help Global does not endorse or condone any type of plagiarism.
Subscribe
No Spam
© 2023 Homework Help Global. All rights reserved.
Homework Help Global will be listed as ‘Homework Help Global’ on your bank statement.