SlideShare a Scribd company logo
1 of 4
Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research and
Applications (IJERA) ISSN: 2248-9622 www.ijera.com
Vol. 3, Issue 3, May-Jun 2013, pp. 1346-1349
1346 | P a g e
A new approach to solve n-queens problem based on series
Vishal Kesri, Manoj Kumar Mishra
School of Computer Engineering KIIT University, India
Abstract
The N-queens problem is a popular
classic puzzle where numbers of queen were to be
placed on an n x n matrix such that no queen can
attack any other queen. The Branching Factor
grows in a roughly linear way, which is an
important consideration for the researchers.
However, many researchers have cited the issues
with help of artificial intelligence search patterns
say DFS, BFS and backtracking algorithms. The
proposed algorithm is able to compute one
unique solution in polynomial time when chess
board size is greater than 7. This algorithm is
based on 8 different series. For each series a
different approach is taken to place the queen on
a given chess board.
General Terms: N-Queen, Knight move, NP-
hard.
Keywords: Analyzer, Move, Rule, Partz.
I. INTRODUCTION
The n-queens problem is proposed for the
first time in 1850 by Carl Gauss. It is to determine a
placement of n queens on an n × n chessboard, such
that no two queens can attack each other [3]. This
problem falls in a special class of problems well
known as NP hard, whose solution cannot be found
out in polynomial time. Let’s consider the 8-queen
problem, which is computationally very expensive
since the total number of possible arrangements
queen is 64! / (56! x 8!) ~ 4.4 x 109
and the total
number of possible solutions are 92 [1]. But there
exists only 12 unique solutions. There are some
solutions that are to be the same and can be obtained
one from the other by taking rotations or symmetry.
The n-queen problem follows the same rules as in 8-
queen problem with N queens and an n x n
chessboard. Current knowledge of total number of
solutions of n-queens problem can be viewed from
the Table 1.
A. Applications
The N-queen problem can be applied in
many different areas, like parallel memory storage
schemes, VLSI testing, traffic control and deadlock
prevention. It is also applicable to find solutions of
those problems which require permutations like
travelling salesman problem [1].
N: Unique Solution Distinct Solution
1 1 1
2 0 0
3 0 0
4 1 2
5 2 10
6 1 4
7 6 40
8 12 92
9 46 352
10 92 724
11 341 2680
12 1787 14200
13 9233 73712
14 45752 365596
Table 1: The number of total and unique solutions
for the
N-Queens problem
II. N-QUEENS PROBLEM DEFINATION
The n-queens Problem of size n, where
need to place n queen into n × n chessboard, so that
no two queen can attack each other that is no two of
them are on the same row, column, or diagonal.
Therefore the rules to obtain the solution of n-
queens problem are follows [5]:
1. Only one queen can placed in each row
2. Only one queen can placed in each column
3. At any time maximum one queen can be in the
diagonal.
Suppose two queen are placed at position (i, j) and
(k, l). Then they are on the same diagonal only if
A. Notation
Here some notations are defined, which are
used in the propose algorithm .These notations are
defined in table 2.
Symbols Definition
S1 Positive Integer Series-A1
S2 Positive Integer Series-A2
S3 Positive Integer Series-A3
S4 Positive Integer Series-A4
Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research and
Applications (IJERA) ISSN: 2248-9622 www.ijera.com
Vol. 3, Issue 3, May-Jun 2013, pp. 1346-1349
1347 | P a g e
S5 Positive Integer Series-A5
S6 Positive Integer Series-A6
S7 Positive Integer Series-A7
S8 Positive Integer Series-A8
R1 Rule-1, used to get the solution.
R2 Rule-2, used to get the solution.
MV1 It is first move function, which
defines the pattern of placing the
queens.
MV2 It is second move function, which
defines the pattern of placing the
queens.
MV3 It is third move function, which
defines the pattern of placing the
queens.
‘n’ Given number of queen (Input Size)
‘Cij’ Cell position of the chess board.
Table-2: List of Symbols
III. SERIES
The Proposed algorithm is a combination
of two rules and eight distinct series. These series
are given below:
A. Series- A1
The Series- A1 is used to get the solution such that:
B. Series- A2
The Series- A2 is used to get the solution such that:
C. Series- A3
The Series- A3 is used to get the solution such
that:
D. Series- A4
The Series- A4 is used to get the solution such that:
E. Series- A5
The Series- A6 is used to get the solution such
that:
F. Series- A6
The Series- A6 is used to get the solution such that:
G. Series- A7
The Series- A7 is used to get the solution such
that:
H. Series- A8
The Series- A8 is used to get the solution such
that:
IV. RULES
There are two Rules, which is used with a
particular series to achieve a solution for a given
chess board. Some series do not need any of the
rules, such as Series-A.
Analyzer: The core of these rules is an analyzer
function. The function of the analyzer is described
as below.
Step-1: initialize the cell ‘Cij’ of chess board to zero,
except where, ‘Cij’ already acquired by a queen.
0 Q 0 0 0
0 0 0 0 Q
0 0 0 0 0
0 0 0 0 0
0 0 Q 0 0
Figure-1: Put Zero in remaining ‘Cij’
Step-2: In the beginning take any queen and add ‘1’
to the value of its attacking cells. Then this step is
repeated for each queen as shown in figure 2.
1 Q 3 2 2
2 2 3 2 Q
2 3 3 3 2
1 2 2 2 3
1 2 Q 1 2
Figure-2: The value of each ‘Cij’ after step 2
The ‘Cij’ values shown in the figure 2 indicates that
the position Cij is attacked by that many queens e.g.
‘C23’ has an integer value 3, that means this cell is
attacked by 3 different queens e.g. by C12 ,C25 ,C53.
Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research and
Applications (IJERA) ISSN: 2248-9622 www.ijera.com
Vol. 3, Issue 3, May-Jun 2013, pp. 1346-1349
1348 | P a g e
First Rule: First rule is applied to find the
solution lies in the series S2 from the solution of S1.
Algorithm of First Rule is described below:
Algorithm for “Rule”
Step-1: If the solution falls in any one of the series
(S1, S3)
Step-2: Increase the dimension of the chess board by
one, that is row +1 and column +1
Step-4: Call Analyzer function with this updated
dimensions
Step-5: Place a queen, where “Cij= =0”
Algorithm-1: Describe Steps of first Rule
Second Rule: Second rule is applied to find the
solution lies in the series S6 from the solution of S5.
The conditions for the second rule is “remove the
queen from Cij If Cin = = C1j = = 1 and |i-1| ≠ |n-j|.
And place queens at the positions C1j and Cin.
Algorithm of second Rule is described below:
Algorithm of Second Rule
Step-1: If the solution falls in any one of the
series (S5)
Step-2: Increase the dimension of the chess
board by one, that is row +1 and column +1
Step-3: Call Analyzer function with this
updated dimensions
Step-4: Remove Queen from Cij
Step-5: Call Analyzer function with this
updated dimensions
Step-6: Place queen, where “Cij= =0”
Algorithm-2: Describe Steps of second Rule
Table 3 show which series those rules apply:
S1 S2 S3 S4 S5 S6 S7 S8
R1        
R2        
Table-3
V. Move Function
MV function shows us the pattern of
placing queen on chess board. There is three Move
Functions defined namely MV1, MV2 and MV3. The
move function along with a particular series defines
the placement of queens on the chess board. The
algorithm for placing queen according to pattern is
described below:
Move-1: This function increases the row value of
the chess board by 3 and reduces the column value
by 1. Algorithm-3 for MV1 is given below.
Algorithm for “MV1”
/* The Place of first queen depend on series */
/* i = row value */
Cij Place First Queen
fora=1 to a ≤ n
i = i+3;
j = j-1;
Cij Place Queen
a = i;
Algorithm-3: Algorithm for MV1 function
Move-2: This function increases the row value of
the chess board by 2 and reduces the column value
by 1. Algorithm-4 for MV2 is given below.
Algorithm for “MV2”
/* The Place of first queen depend on series */
/* i = row value */
Cij Place First Queen
fora=1 to a ≤ n
i = i+2;
j = j-1;
Cij Place Queen
a = i;
Algorithm-4: Algorithm for MV2 function
Move-3: This function decreases the row value of
the chess board by 2 and increase column value by 3
or decrease column value by 1. Algorithm-5 for
MV3 is given below.
Algorithm for “MV3”
/* The Place of first queen depend on series */
/* i = row value, j = Column */
count = 0;
Cij Place First Queen
fora=n to a ≥ 1
i = i-2;
if (count % 2 =0 )
j = j+3;
else
j = j-1;
Cij Place Queen
a = i;
Algorithm-5: Algorithm for MV3 function
Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research and
Applications (IJERA) ISSN: 2248-9622 www.ijera.com
Vol. 3, Issue 3, May-Jun 2013, pp. 1346-1349
1349 | P a g e
Table-4 shows, which move function is applied on
what series.
S1 S2 S3 S4 S5 S6 S7 S8
MV1        
MV2        
MV3        
Table-4
Algorithm for n-queens
The proposed algorithm finds a unique
solution of n-queens problem, which is described
below:
Algorithm to solve n-queens Problem
Step1:
Step2: If
{
Call “MV1”, where i = 1 && j = n/3
Call “MV1”, where i = 2 && j = (n/3) *2
Call “MV1”, where i = 3 && j = n
}
Step3: If
{
Get the solution of “n-1” chess board
/* n-1 chess board ∈ S1 */
Apply ‘R1’
}
Step4: If
{
Call “MV1”, where i = 2 && j = (n-1)/3
Call “MV1”, where i = 1 && j = (n-1/3)
*2+1
Call “MV1”, where i = 3 && j = n
}
Step5: If
{
Get the solution of “n-1” chess board
/* n-1 chess board ∈ S3 */
Apply ‘R1’
}
Step6: If
{
Call “MV2”, where i = 1 && j = n/2
Call “MV3”, where i = n && j = (n/2) + 2
}
Step7: If
{
Call “MV2”, where i = 2 && j = (n-1)/2
Call “MV3”, where i = n && j = (n-1)/2 +2
Apply ‘R2’
}
Step8: If
{
Call “MV2”, where i = 1 && j = (n/2) + 1
Call “MV3”, where i = n && j = (n/2) + 3
Place Queen At Cij, Where i = 2 && j = 1
}
Step9: If
{
Call “MV2”, where i = 1 && j = (n-1) /2+2
Call “MV3”, where i = n && j = (n-1) /2) + 4
Place Queen At Cij, Where i = 1 && j = 1
Place Queen At Cij, Where i = 3 && j = 2
}
Algorithm-6: Algorithm for Calculate Solution of
N-Queen
VI. DISADVANTAGE
The proposed algorithm provides only one
unique solution when chess board size is greater
than 7 and the algorithm is not able to provide all
the solutions. By Rotation of chess board we can get
few more solutions but those solutions are not
distinct.
VII. CONCLUSION AND FUTURE
WORK
This Algorithm provides only one unique
solution for n > 7. This method can be enhanced in
future to find all other solutions.
REFERENCES
[1] V. Kesri, Va. Kesri and P. Ku. Pattnaik.
“An Unique Solution for N queen Problem”.
International Journal of Computer
Applications.Vol:43 Issue:12 pp: 1-6, 2012.
[2] Gutiérrez-Naranjo, Miguel A., Martínez –
del - Amor Miguel A. , Pérez-Hurtado
Ignacio, and Pérez-Jiménez Mario J. February
02, 2009. “Solving the N-Queens Puzzle with
P Systems”, 7th Brainstorming Week on
Membrane Computing, volume 1, pp199-210.
[3] Letavec, C. and Ruggiero, J. 2002. “The n-
queen problem”, Informs Transaction on
Education, volume 2 number 3, May 2002.
[4] Uninformed Search Analysis of the N-queens
Problem, Ben Sauerwine, September 20,
2003. Available at:
http://www.andrew.cmu.edu/user/bsauerwi/re
search/P1.pdf
[5] Russell, S. and Norvig, P. “Artificial
Intelligence A Modern Approach”, Second
Edition, pp 139-140.
[6] Ellis Horowitz, Sartaj Sahni, Sanguthevar
Rajasekaran, “Fundamental of computer
Algorithm (pp 339)”.
[7] S.Ahmadi V. Kesri, and Va. Kesri.
“Clustering in backtracking for solution of N-
queen Problem”. Third International
Conference on Contemporary Issues in
Computer and Information Sciences CICIS
2012

More Related Content

Viewers also liked (20)

Hm3312981305
Hm3312981305Hm3312981305
Hm3312981305
 
Hg3312711275
Hg3312711275Hg3312711275
Hg3312711275
 
Im3115911596
Im3115911596Im3115911596
Im3115911596
 
Ir3116271633
Ir3116271633Ir3116271633
Ir3116271633
 
Ab34169175
Ab34169175Ab34169175
Ab34169175
 
Af34193199
Af34193199Af34193199
Af34193199
 
Ai34212218
Ai34212218Ai34212218
Ai34212218
 
A340105
A340105A340105
A340105
 
Ah34207211
Ah34207211Ah34207211
Ah34207211
 
Ac34176185
Ac34176185Ac34176185
Ac34176185
 
As35252256
As35252256As35252256
As35252256
 
Ap35235240
Ap35235240Ap35235240
Ap35235240
 
Ak35206217
Ak35206217Ak35206217
Ak35206217
 
An35225228
An35225228An35225228
An35225228
 
Ai35194197
Ai35194197Ai35194197
Ai35194197
 
Cv35547551
Cv35547551Cv35547551
Cv35547551
 
Di32687692
Di32687692Di32687692
Di32687692
 
Leyenda fuensanta
Leyenda fuensantaLeyenda fuensanta
Leyenda fuensanta
 
Presentacion Tequila Nock Premium
Presentacion Tequila Nock PremiumPresentacion Tequila Nock Premium
Presentacion Tequila Nock Premium
 
Guerra civil española Jose antonio diaz romero
Guerra civil española Jose antonio diaz romeroGuerra civil española Jose antonio diaz romero
Guerra civil española Jose antonio diaz romero
 

Similar to Ht3313461349

K means clustering algorithm
K means clustering algorithmK means clustering algorithm
K means clustering algorithmDarshak Mehta
 
Skiena algorithm 2007 lecture15 backtracing
Skiena algorithm 2007 lecture15 backtracingSkiena algorithm 2007 lecture15 backtracing
Skiena algorithm 2007 lecture15 backtracingzukun
 
Solution of matlab chapter 3
Solution of matlab chapter 3Solution of matlab chapter 3
Solution of matlab chapter 3AhsanIrshad8
 
Chapter 3: Linear Systems and Matrices - Part 2/Slides
Chapter 3: Linear Systems and Matrices - Part 2/SlidesChapter 3: Linear Systems and Matrices - Part 2/Slides
Chapter 3: Linear Systems and Matrices - Part 2/SlidesChaimae Baroudi
 
MODULE_05-Matrix Decomposition.pptx
MODULE_05-Matrix Decomposition.pptxMODULE_05-Matrix Decomposition.pptx
MODULE_05-Matrix Decomposition.pptxAlokSingh205089
 
12 Speed Gear Box Theory Notes by Prof. Sagar Dhotare
12 Speed Gear Box Theory Notes by Prof. Sagar Dhotare12 Speed Gear Box Theory Notes by Prof. Sagar Dhotare
12 Speed Gear Box Theory Notes by Prof. Sagar DhotareSagar Dhotare
 
Quantum Computing Notes Ver 1.2
Quantum Computing Notes Ver 1.2Quantum Computing Notes Ver 1.2
Quantum Computing Notes Ver 1.2Vijayananda Mohire
 
GRAPH - DISCRETE STRUCTURE AND ALGORITHM
GRAPH - DISCRETE STRUCTURE AND ALGORITHMGRAPH - DISCRETE STRUCTURE AND ALGORITHM
GRAPH - DISCRETE STRUCTURE AND ALGORITHMhimanshumishra19dec
 
Transportation and transshipment problems
Transportation  and transshipment problemsTransportation  and transshipment problems
Transportation and transshipment problemsDr. Adinath Damale
 
Calculating Mine Probability in Minesweeper
Calculating Mine Probability in MinesweeperCalculating Mine Probability in Minesweeper
Calculating Mine Probability in MinesweeperLukeVideckis
 
Matrices & Determinants
Matrices & DeterminantsMatrices & Determinants
Matrices & DeterminantsIshant Jain
 
Algorithm Performance For Chessboard Separation Problems
Algorithm Performance For Chessboard Separation ProblemsAlgorithm Performance For Chessboard Separation Problems
Algorithm Performance For Chessboard Separation ProblemsTina Gabel
 
Two algorithms to accelerate training of back-propagation neural networks
Two algorithms to accelerate training of back-propagation neural networksTwo algorithms to accelerate training of back-propagation neural networks
Two algorithms to accelerate training of back-propagation neural networksESCOM
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesOmprakash Chauhan
 

Similar to Ht3313461349 (20)

DAA Notes.pdf
DAA Notes.pdfDAA Notes.pdf
DAA Notes.pdf
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Ma3bfet par 10.6 5 aug 2014
Ma3bfet par 10.6 5 aug 2014Ma3bfet par 10.6 5 aug 2014
Ma3bfet par 10.6 5 aug 2014
 
K means clustering algorithm
K means clustering algorithmK means clustering algorithm
K means clustering algorithm
 
Skiena algorithm 2007 lecture15 backtracing
Skiena algorithm 2007 lecture15 backtracingSkiena algorithm 2007 lecture15 backtracing
Skiena algorithm 2007 lecture15 backtracing
 
Solution of matlab chapter 3
Solution of matlab chapter 3Solution of matlab chapter 3
Solution of matlab chapter 3
 
Chapter 3: Linear Systems and Matrices - Part 2/Slides
Chapter 3: Linear Systems and Matrices - Part 2/SlidesChapter 3: Linear Systems and Matrices - Part 2/Slides
Chapter 3: Linear Systems and Matrices - Part 2/Slides
 
MODULE_05-Matrix Decomposition.pptx
MODULE_05-Matrix Decomposition.pptxMODULE_05-Matrix Decomposition.pptx
MODULE_05-Matrix Decomposition.pptx
 
N Queens problem
N Queens problemN Queens problem
N Queens problem
 
12 Speed Gear Box Theory Notes by Prof. Sagar Dhotare
12 Speed Gear Box Theory Notes by Prof. Sagar Dhotare12 Speed Gear Box Theory Notes by Prof. Sagar Dhotare
12 Speed Gear Box Theory Notes by Prof. Sagar Dhotare
 
Quantum Computing Notes Ver 1.2
Quantum Computing Notes Ver 1.2Quantum Computing Notes Ver 1.2
Quantum Computing Notes Ver 1.2
 
GRAPH - DISCRETE STRUCTURE AND ALGORITHM
GRAPH - DISCRETE STRUCTURE AND ALGORITHMGRAPH - DISCRETE STRUCTURE AND ALGORITHM
GRAPH - DISCRETE STRUCTURE AND ALGORITHM
 
Transportation and transshipment problems
Transportation  and transshipment problemsTransportation  and transshipment problems
Transportation and transshipment problems
 
Calculating Mine Probability in Minesweeper
Calculating Mine Probability in MinesweeperCalculating Mine Probability in Minesweeper
Calculating Mine Probability in Minesweeper
 
Matrices & Determinants
Matrices & DeterminantsMatrices & Determinants
Matrices & Determinants
 
Algorithm Performance For Chessboard Separation Problems
Algorithm Performance For Chessboard Separation ProblemsAlgorithm Performance For Chessboard Separation Problems
Algorithm Performance For Chessboard Separation Problems
 
1st Semester Physics Cycle (Dec-2015; Jan-2016) Question Papers
1st Semester Physics Cycle  (Dec-2015; Jan-2016) Question Papers1st Semester Physics Cycle  (Dec-2015; Jan-2016) Question Papers
1st Semester Physics Cycle (Dec-2015; Jan-2016) Question Papers
 
Two algorithms to accelerate training of back-propagation neural networks
Two algorithms to accelerate training of back-propagation neural networksTwo algorithms to accelerate training of back-propagation neural networks
Two algorithms to accelerate training of back-propagation neural networks
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
Simplex method
Simplex methodSimplex method
Simplex method
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 

Ht3313461349

  • 1. Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622 www.ijera.com Vol. 3, Issue 3, May-Jun 2013, pp. 1346-1349 1346 | P a g e A new approach to solve n-queens problem based on series Vishal Kesri, Manoj Kumar Mishra School of Computer Engineering KIIT University, India Abstract The N-queens problem is a popular classic puzzle where numbers of queen were to be placed on an n x n matrix such that no queen can attack any other queen. The Branching Factor grows in a roughly linear way, which is an important consideration for the researchers. However, many researchers have cited the issues with help of artificial intelligence search patterns say DFS, BFS and backtracking algorithms. The proposed algorithm is able to compute one unique solution in polynomial time when chess board size is greater than 7. This algorithm is based on 8 different series. For each series a different approach is taken to place the queen on a given chess board. General Terms: N-Queen, Knight move, NP- hard. Keywords: Analyzer, Move, Rule, Partz. I. INTRODUCTION The n-queens problem is proposed for the first time in 1850 by Carl Gauss. It is to determine a placement of n queens on an n × n chessboard, such that no two queens can attack each other [3]. This problem falls in a special class of problems well known as NP hard, whose solution cannot be found out in polynomial time. Let’s consider the 8-queen problem, which is computationally very expensive since the total number of possible arrangements queen is 64! / (56! x 8!) ~ 4.4 x 109 and the total number of possible solutions are 92 [1]. But there exists only 12 unique solutions. There are some solutions that are to be the same and can be obtained one from the other by taking rotations or symmetry. The n-queen problem follows the same rules as in 8- queen problem with N queens and an n x n chessboard. Current knowledge of total number of solutions of n-queens problem can be viewed from the Table 1. A. Applications The N-queen problem can be applied in many different areas, like parallel memory storage schemes, VLSI testing, traffic control and deadlock prevention. It is also applicable to find solutions of those problems which require permutations like travelling salesman problem [1]. N: Unique Solution Distinct Solution 1 1 1 2 0 0 3 0 0 4 1 2 5 2 10 6 1 4 7 6 40 8 12 92 9 46 352 10 92 724 11 341 2680 12 1787 14200 13 9233 73712 14 45752 365596 Table 1: The number of total and unique solutions for the N-Queens problem II. N-QUEENS PROBLEM DEFINATION The n-queens Problem of size n, where need to place n queen into n × n chessboard, so that no two queen can attack each other that is no two of them are on the same row, column, or diagonal. Therefore the rules to obtain the solution of n- queens problem are follows [5]: 1. Only one queen can placed in each row 2. Only one queen can placed in each column 3. At any time maximum one queen can be in the diagonal. Suppose two queen are placed at position (i, j) and (k, l). Then they are on the same diagonal only if A. Notation Here some notations are defined, which are used in the propose algorithm .These notations are defined in table 2. Symbols Definition S1 Positive Integer Series-A1 S2 Positive Integer Series-A2 S3 Positive Integer Series-A3 S4 Positive Integer Series-A4
  • 2. Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622 www.ijera.com Vol. 3, Issue 3, May-Jun 2013, pp. 1346-1349 1347 | P a g e S5 Positive Integer Series-A5 S6 Positive Integer Series-A6 S7 Positive Integer Series-A7 S8 Positive Integer Series-A8 R1 Rule-1, used to get the solution. R2 Rule-2, used to get the solution. MV1 It is first move function, which defines the pattern of placing the queens. MV2 It is second move function, which defines the pattern of placing the queens. MV3 It is third move function, which defines the pattern of placing the queens. ‘n’ Given number of queen (Input Size) ‘Cij’ Cell position of the chess board. Table-2: List of Symbols III. SERIES The Proposed algorithm is a combination of two rules and eight distinct series. These series are given below: A. Series- A1 The Series- A1 is used to get the solution such that: B. Series- A2 The Series- A2 is used to get the solution such that: C. Series- A3 The Series- A3 is used to get the solution such that: D. Series- A4 The Series- A4 is used to get the solution such that: E. Series- A5 The Series- A6 is used to get the solution such that: F. Series- A6 The Series- A6 is used to get the solution such that: G. Series- A7 The Series- A7 is used to get the solution such that: H. Series- A8 The Series- A8 is used to get the solution such that: IV. RULES There are two Rules, which is used with a particular series to achieve a solution for a given chess board. Some series do not need any of the rules, such as Series-A. Analyzer: The core of these rules is an analyzer function. The function of the analyzer is described as below. Step-1: initialize the cell ‘Cij’ of chess board to zero, except where, ‘Cij’ already acquired by a queen. 0 Q 0 0 0 0 0 0 0 Q 0 0 0 0 0 0 0 0 0 0 0 0 Q 0 0 Figure-1: Put Zero in remaining ‘Cij’ Step-2: In the beginning take any queen and add ‘1’ to the value of its attacking cells. Then this step is repeated for each queen as shown in figure 2. 1 Q 3 2 2 2 2 3 2 Q 2 3 3 3 2 1 2 2 2 3 1 2 Q 1 2 Figure-2: The value of each ‘Cij’ after step 2 The ‘Cij’ values shown in the figure 2 indicates that the position Cij is attacked by that many queens e.g. ‘C23’ has an integer value 3, that means this cell is attacked by 3 different queens e.g. by C12 ,C25 ,C53.
  • 3. Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622 www.ijera.com Vol. 3, Issue 3, May-Jun 2013, pp. 1346-1349 1348 | P a g e First Rule: First rule is applied to find the solution lies in the series S2 from the solution of S1. Algorithm of First Rule is described below: Algorithm for “Rule” Step-1: If the solution falls in any one of the series (S1, S3) Step-2: Increase the dimension of the chess board by one, that is row +1 and column +1 Step-4: Call Analyzer function with this updated dimensions Step-5: Place a queen, where “Cij= =0” Algorithm-1: Describe Steps of first Rule Second Rule: Second rule is applied to find the solution lies in the series S6 from the solution of S5. The conditions for the second rule is “remove the queen from Cij If Cin = = C1j = = 1 and |i-1| ≠ |n-j|. And place queens at the positions C1j and Cin. Algorithm of second Rule is described below: Algorithm of Second Rule Step-1: If the solution falls in any one of the series (S5) Step-2: Increase the dimension of the chess board by one, that is row +1 and column +1 Step-3: Call Analyzer function with this updated dimensions Step-4: Remove Queen from Cij Step-5: Call Analyzer function with this updated dimensions Step-6: Place queen, where “Cij= =0” Algorithm-2: Describe Steps of second Rule Table 3 show which series those rules apply: S1 S2 S3 S4 S5 S6 S7 S8 R1         R2         Table-3 V. Move Function MV function shows us the pattern of placing queen on chess board. There is three Move Functions defined namely MV1, MV2 and MV3. The move function along with a particular series defines the placement of queens on the chess board. The algorithm for placing queen according to pattern is described below: Move-1: This function increases the row value of the chess board by 3 and reduces the column value by 1. Algorithm-3 for MV1 is given below. Algorithm for “MV1” /* The Place of first queen depend on series */ /* i = row value */ Cij Place First Queen fora=1 to a ≤ n i = i+3; j = j-1; Cij Place Queen a = i; Algorithm-3: Algorithm for MV1 function Move-2: This function increases the row value of the chess board by 2 and reduces the column value by 1. Algorithm-4 for MV2 is given below. Algorithm for “MV2” /* The Place of first queen depend on series */ /* i = row value */ Cij Place First Queen fora=1 to a ≤ n i = i+2; j = j-1; Cij Place Queen a = i; Algorithm-4: Algorithm for MV2 function Move-3: This function decreases the row value of the chess board by 2 and increase column value by 3 or decrease column value by 1. Algorithm-5 for MV3 is given below. Algorithm for “MV3” /* The Place of first queen depend on series */ /* i = row value, j = Column */ count = 0; Cij Place First Queen fora=n to a ≥ 1 i = i-2; if (count % 2 =0 ) j = j+3; else j = j-1; Cij Place Queen a = i; Algorithm-5: Algorithm for MV3 function
  • 4. Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622 www.ijera.com Vol. 3, Issue 3, May-Jun 2013, pp. 1346-1349 1349 | P a g e Table-4 shows, which move function is applied on what series. S1 S2 S3 S4 S5 S6 S7 S8 MV1         MV2         MV3         Table-4 Algorithm for n-queens The proposed algorithm finds a unique solution of n-queens problem, which is described below: Algorithm to solve n-queens Problem Step1: Step2: If { Call “MV1”, where i = 1 && j = n/3 Call “MV1”, where i = 2 && j = (n/3) *2 Call “MV1”, where i = 3 && j = n } Step3: If { Get the solution of “n-1” chess board /* n-1 chess board ∈ S1 */ Apply ‘R1’ } Step4: If { Call “MV1”, where i = 2 && j = (n-1)/3 Call “MV1”, where i = 1 && j = (n-1/3) *2+1 Call “MV1”, where i = 3 && j = n } Step5: If { Get the solution of “n-1” chess board /* n-1 chess board ∈ S3 */ Apply ‘R1’ } Step6: If { Call “MV2”, where i = 1 && j = n/2 Call “MV3”, where i = n && j = (n/2) + 2 } Step7: If { Call “MV2”, where i = 2 && j = (n-1)/2 Call “MV3”, where i = n && j = (n-1)/2 +2 Apply ‘R2’ } Step8: If { Call “MV2”, where i = 1 && j = (n/2) + 1 Call “MV3”, where i = n && j = (n/2) + 3 Place Queen At Cij, Where i = 2 && j = 1 } Step9: If { Call “MV2”, where i = 1 && j = (n-1) /2+2 Call “MV3”, where i = n && j = (n-1) /2) + 4 Place Queen At Cij, Where i = 1 && j = 1 Place Queen At Cij, Where i = 3 && j = 2 } Algorithm-6: Algorithm for Calculate Solution of N-Queen VI. DISADVANTAGE The proposed algorithm provides only one unique solution when chess board size is greater than 7 and the algorithm is not able to provide all the solutions. By Rotation of chess board we can get few more solutions but those solutions are not distinct. VII. CONCLUSION AND FUTURE WORK This Algorithm provides only one unique solution for n > 7. This method can be enhanced in future to find all other solutions. REFERENCES [1] V. Kesri, Va. Kesri and P. Ku. Pattnaik. “An Unique Solution for N queen Problem”. International Journal of Computer Applications.Vol:43 Issue:12 pp: 1-6, 2012. [2] Gutiérrez-Naranjo, Miguel A., Martínez – del - Amor Miguel A. , Pérez-Hurtado Ignacio, and Pérez-Jiménez Mario J. February 02, 2009. “Solving the N-Queens Puzzle with P Systems”, 7th Brainstorming Week on Membrane Computing, volume 1, pp199-210. [3] Letavec, C. and Ruggiero, J. 2002. “The n- queen problem”, Informs Transaction on Education, volume 2 number 3, May 2002. [4] Uninformed Search Analysis of the N-queens Problem, Ben Sauerwine, September 20, 2003. Available at: http://www.andrew.cmu.edu/user/bsauerwi/re search/P1.pdf [5] Russell, S. and Norvig, P. “Artificial Intelligence A Modern Approach”, Second Edition, pp 139-140. [6] Ellis Horowitz, Sartaj Sahni, Sanguthevar Rajasekaran, “Fundamental of computer Algorithm (pp 339)”. [7] S.Ahmadi V. Kesri, and Va. Kesri. “Clustering in backtracking for solution of N- queen Problem”. Third International Conference on Contemporary Issues in Computer and Information Sciences CICIS 2012