N Queen Puzzle https://en.wikipedia.org/wiki/Eight_queens_puzzle Backtracking Algorithm 1. Starting from first row, loop through all the positions in this.

Slides:



Advertisements
Similar presentations
3.5 Graphs in Three Dimensions 2.Graphing Equations in Three Dimensions.
Advertisements

6.4: Coordinates in Three Dimensions
1/16/ : Coordinates in 3 Dimensions 6.4: Coordinates in Three Dimensions Expectations: G1.1.5: Given a segment in terms of its endpoints, determine.
Polynomial Time Algorithms for the N-Queen Problem Rok sosic and Jun Gu.
Solving N+k Queens Using Dancing Links Matthew A. Wolff Morehead State University May 19, 2006.
Local Search Algorithms Chapter 4. Outline Hill-climbing search Simulated annealing search Local beam search Genetic algorithms Ant Colony Optimization.
ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.
Announcements Assignment #4 is due tonight. Last lab program is going to be assigned this Wednesday. ◦ A backtracking problem.
The N-Queens Problem lab01.
Eight queens puzzle. The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard such that none of them are able to capture.
Backtracking COP Backtracking  Backtracking is a technique used to solve problems with a large search space, by systematically trying and eliminating.
CSC212 Data Structure - Section FG Lecture 12 Stacks and Queues Instructor: Zhigang Zhu Department of Computer Science City College of New York.
Backtracking CSC 172 SPRING 2004 LECTURE 11. Reminders  Project 3 (mastermind) is due before Spring break  Friday, March 5 th 5PM  Computer Science.
CS 206 Introduction to Computer Science II 03 / 30 / 2009 Instructor: Michael Eckmann.
Problem Solving Through Coding Names. PROBLEM SOLVING PROCESS UNDERSTAND THE PROBLEM: READ OR LISTEN TO THE PROBLEM. MAKE A PLAN TO SOVLE THE PROBLEM-
Lesson 9.8. Warm Up Evaluate for x = –2, y = 3, and z = – x 2 2. xyz 3. x 2 – yz4. y – xz 4 5. –x 6. z 2 – xy
Lecture 17: Spanning Trees Minimum Spanning Trees.
Vlad Furash & Steven Wine.  Problem surfaced in 1848 by chess player Max Bezzel as 8 queens (regulation board size)  Premise is to place N queens on.
Boggle Game: Backtracking Algorithm Implementation
Vector Calculus.
Back Tracking Project Due August 11, 1999 N-queens: –A classic puzzle for chess buffs is the N- Queens problem. Simply stated: is it possible to place.
HISTORY The problem was originally proposed in 1848 by the chess player Max Bezzel, and over the years, many mathematicians, including Gauss have worked.
NxN Queens Problem Q- -- -Q Q- -- -Q Q- -- QQ -- Q- Q- Q- -Q QQ -- -Q -- -Q Q- -Q -Q Q- Q- -Q Q- -- Q- -- QQ Q- -Q -Q -Q -- QQ -- -Q START.
Two Dimensional Arrays
Computational Geometry Piyush Kumar (Lecture 10: Point Location) Welcome to CIS5930.
Announcements This Wednesday, Class and Labs are cancelled! The last lab is due this Wednesday … how many people are planning on doing it? Finally posted.
Department of Computer Science 1 Recursion & Backtracking 1.The game of NIM 2.Getting out of a maze 3.The 8 Queen’s Problem 4.Sudoku.
CS 100Lecture 191 CS100J Lecture 19 n Previous Lecture –Two dimensional arrays. –Reasonable size problem (a past assignment). –Stepwise refinement. –Use.
CompSci 100e 6.1 Plan for the week l More recursion examples l Backtracking  Exhaustive incremental search  When we a potential solution is invalid,
Chapter 6 Questions Quick Quiz
© 2013 Pearson Education, Inc. 12G Vectors in Space.
© 2006 Pearson Addison-Wesley. All rights reserved 6-1 Chapter 6 Recursion as a Problem- Solving Technique.
Analysis & Design of Algorithms (CSCE 321)
N- Queens Solution with Genetic Algorithm By Mohammad A. Ismael.
XDI RDF Graphing V x+y $has +x+y $has +x+y +x/$has/+y +x+y +x+y $has +x+y/$has/+z +x/$has/+y+z +x+y+z +x+y+z $has +z +x+y+z $has 3 4 Full.
Part 2 # 68 Longest Common Subsequence T.H. Cormen et al., Introduction to Algorithms, MIT press, 3/e, 2009, pp Example: X=abadcda, Y=acbacadb.
CPS Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze ä Certain mazes can be solved using the “right-hand”
Speaker: Fuw-Yi Yang 楊伏夷 伏夷非征番, 道德經 察政章(Chapter 58) 伏者潛藏也
Copyright © Cengage Learning. All rights reserved.
EXAMPLES- Simplifying Radicals part 2
For loops, nested loops and scopes
Data Structures and Algorithms
Fundamentals of Programming II Backtracking with Stacks
Sit-In Lab 1 Ob-CHESS-ion
Intersection between - Lines, - Planes and - a plane & a Line
Systems of Linear Equations
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
3.4 Solving Systems of Linear Equations in Three Variables
Copyright © Cengage Learning. All rights reserved.
Computer Science cpsc322, Lecture 14
Drawing Triangles.
Back Tracking.
Some Theorems Thm. Divergence Theorem
Find the curl of the vector field. {image}
Copyright © Cengage Learning. All rights reserved.
Objective: Today we will investigate the ‘magic’ in magic squares.
Copyright © Cengage Learning. All rights reserved.
Dynamic Programming Computation of Edit Distance
Unit 5 COMBINATIONAL CIRCUITS-1
Find the curl of the vector field. {image}
Mobile Robot Kinematics
Copyright © Cengage Learning. All rights reserved.
CS Software Studio Assignment 1
F(x, y) = P(x, y)i + Q(x, y)j = < P(x, y), Q(x, y) > F = Pi + Qj
Position Vectors Distance between 2 points
Space groups Start w/ 2s and 21s 222.
Announcements Assignment #4 is due tonight. Last lab program is going to be assigned this Wednesday. ◦ A backtracking problem.
3.5 Graphs in Three Dimensions (Day 1)
Missing values multiplying monomial.
Presentation transcript:

N Queen Puzzle Backtracking Algorithm 1. Starting from first row, loop through all the positions in this row, if could find a safe position, mark it and move forward to next row. 2. If you can a safe position in the next row, keep moving forward. If this finally leads to a solution, save it. Otherwise transverse back to previous row to look for other possible safe positions 3. Repeat until we have looped through all positions type Board struct { field [][]int} type Boards []Board Shuo Zhao

Independent Solutions N=4 Independent Solutions N=4 Solutions N=5, 6, 7, 8 Solutions N Ind All

Nonstandard Board ShapestandardcolumnDonut Attacking conditionsx=i; y=j; abs(x-i)=abs(j-y) x=i; y=j; abs(x-i)=abs(j-y) abs(x-i)=abs(j+n-y) abs(x-i)=abs(j-n-y) x=i; y=j; abs(x-i)=abs(j-y) abs(x-i)=abs(j+n-y) abs(x-i)=abs(j-n-y) abs(x+n-i)=abs(j-y) abs(x-n-i)=abs(j-y) Higher Dimensional Board (3d as example) abs(x-i)=abs(y-j)=abs(z-k) (3dimensional diagonal) if x=i (yz plane): y=j; z=k; (1dimensional); abs(y-j)=abs(z-k) (2dimensional) if y=i (xz plane): x=i; z=k; (1dimensional); abs(x-i)=abs(z-k) (2dimensional) if z=k (xy plane): y=j; x=i; (1dimensional); abs(y-j)=abs(x-i) (2dimensional) if x!=i&& y!=i&& z!=k (xyz space): abs(x-i)=abs(y-j)=abs(z-k) (3dimensional) Jeremiah Barr and Shrisha Rao, Department of Computer Science, Mount Mercy College, IA _2004/Barr.pdf N=4