SlideShare a Scribd company logo
1
W E L C O M E !
Thank you for coming today!
2
MD. A.I.Tazib
ID: 153-15-6683
INTRODUCTION
5
N Q u e e n
P r o b l e m
The N Queen is the problem of placing N
chess queens on an N×N chessboard so that
no two queens attack each other.
For example, following is a solution for 4
Queen problem.
Solutions
V a r i o u s a p p r o a c h e s :
7
Brute force
Backtracking
Permutation
generation
Graph theory
concepts
Divide and conquer
approach
Mathematical
solutions
Backtracking Solution :
0
1
2
3
0 1 2 3
0
1
2
3
Positions:
9
F i n a l
S o l u t i o n
Q
Q
Q
Q
Bac k trac k ing
Algorithm
Backtracking Algorithm :
1) Start from the left most column.
2) If all Queens are placed
return true.
3) Try all rows in the current column. Do following for every tried row.
a) If the queen can be placed safely in this row then mark this [row,
column] as part of the solution and recursively check if placing
queen here leads to a solution.
b) If placing queen in [row, column] leads to a solution then return
true.
c) If placing queen doesn't lead to a solution then unmark this [row,
column] (Backtrack) and go to step (a) to try other rows.
4) If all rows have been tried and nothing worked, return false to trigger
backtracking.
T H A N K Y O U !
A N Y Q U E S T I O N S ?

More Related Content

PPT
Backtracking Algorithm.ppt
PPTX
N queen puzzle
PPTX
N queens using backtracking
PPTX
The n Queen Problem
PPTX
N queen problem
PDF
N Queens problem
PPT
Backtracking
PPTX
8 queen problem
Backtracking Algorithm.ppt
N queen puzzle
N queens using backtracking
The n Queen Problem
N queen problem
N Queens problem
Backtracking
8 queen problem

What's hot (20)

PPT
UNIT-1-PPTS-DAA.ppt
PPT
6 games
PPT
3.9 external sorting
PPTX
Constraint satisfaction problems (csp)
PPTX
Minimum Spanning Tree
PPTX
Selection sorting
PPTX
Quick sort
PPTX
Tree and graph
PPTX
Regular Expression to Finite Automata
PPTX
Knowledge representation and Predicate logic
PPT
BackTracking Algorithm: Technique and Examples
PPTX
Strongly connected components
PPTX
Dijkstra s algorithm
PPTX
Greedy Algorithms
PPT
Shell sorting
 
PPTX
Data Structure and Algorithms The Tower of Hanoi
PPTX
Quick sort
PPT
Greedy Algorihm
PDF
I. Hill climbing algorithm II. Steepest hill climbing algorithm
UNIT-1-PPTS-DAA.ppt
6 games
3.9 external sorting
Constraint satisfaction problems (csp)
Minimum Spanning Tree
Selection sorting
Quick sort
Tree and graph
Regular Expression to Finite Automata
Knowledge representation and Predicate logic
BackTracking Algorithm: Technique and Examples
Strongly connected components
Dijkstra s algorithm
Greedy Algorithms
Shell sorting
 
Data Structure and Algorithms The Tower of Hanoi
Quick sort
Greedy Algorihm
I. Hill climbing algorithm II. Steepest hill climbing algorithm
Ad

Similar to N Queen Algorithm (20)

PDF
N Queen Problem
PDF
Ai lecture 10(unit02)
PPTX
N-queens.pptx
PPTX
Backtracking Algorithm.pptx
PPTX
8queensproblemusingbacktracking-120903114053-phpapp01.pptx
PPTX
8 QUEENS PROBLEM.pptx
PDF
N queens problem
PPTX
PUZZLE IN C PROGRAMMING
PPTX
Puzzle in c program
PPTX
The N-Queens problemdskksnjfnskjdfnsjnddjsdnjs
PDF
8 Queens Problemyjjffhhhgfghhhfhhggghjgg
PPTX
Backtracking Basics.pptx
PDF
An approach to solve the N-Queens Problem using Artificial Intelligence algor...
PPTX
backtracking 8 Queen.pptx
PDF
module5_backtrackingnbranchnbound_2022.pdf
PPTX
proficiency presenattion on topic of backtracking algo
PDF
Constraint Satisfaction Problem (CSP) by A z m jalal uddin joy_v1.0.1
PDF
Genetic Algorithm Artificial Intelligence
PPTX
data structures- back tracking
PPTX
Lecture2b algorithm
N Queen Problem
Ai lecture 10(unit02)
N-queens.pptx
Backtracking Algorithm.pptx
8queensproblemusingbacktracking-120903114053-phpapp01.pptx
8 QUEENS PROBLEM.pptx
N queens problem
PUZZLE IN C PROGRAMMING
Puzzle in c program
The N-Queens problemdskksnjfnskjdfnsjnddjsdnjs
8 Queens Problemyjjffhhhgfghhhfhhggghjgg
Backtracking Basics.pptx
An approach to solve the N-Queens Problem using Artificial Intelligence algor...
backtracking 8 Queen.pptx
module5_backtrackingnbranchnbound_2022.pdf
proficiency presenattion on topic of backtracking algo
Constraint Satisfaction Problem (CSP) by A z m jalal uddin joy_v1.0.1
Genetic Algorithm Artificial Intelligence
data structures- back tracking
Lecture2b algorithm
Ad

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
01-Introduction-to-Information-Management.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Institutional Correction lecture only . . .
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Complications of Minimal Access Surgery at WLH
PPTX
master seminar digital applications in india
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
2.FourierTransform-ShortQuestionswithAnswers.pdf
Cell Structure & Organelles in detailed.
01-Introduction-to-Information-Management.pdf
Insiders guide to clinical Medicine.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Final Presentation General Medicine 03-08-2024.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Anesthesia in Laparoscopic Surgery in India
O7-L3 Supply Chain Operations - ICLT Program
Institutional Correction lecture only . . .
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Complications of Minimal Access Surgery at WLH
master seminar digital applications in india
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf

N Queen Algorithm

  • 1. 1
  • 2. W E L C O M E ! Thank you for coming today! 2
  • 5. 5 N Q u e e n P r o b l e m The N Queen is the problem of placing N chess queens on an N×N chessboard so that no two queens attack each other. For example, following is a solution for 4 Queen problem.
  • 7. V a r i o u s a p p r o a c h e s : 7 Brute force Backtracking Permutation generation Graph theory concepts Divide and conquer approach Mathematical solutions
  • 8. Backtracking Solution : 0 1 2 3 0 1 2 3 0 1 2 3 Positions:
  • 9. 9 F i n a l S o l u t i o n Q Q Q Q
  • 10. Bac k trac k ing Algorithm
  • 11. Backtracking Algorithm : 1) Start from the left most column. 2) If all Queens are placed return true. 3) Try all rows in the current column. Do following for every tried row. a) If the queen can be placed safely in this row then mark this [row, column] as part of the solution and recursively check if placing queen here leads to a solution. b) If placing queen in [row, column] leads to a solution then return true. c) If placing queen doesn't lead to a solution then unmark this [row, column] (Backtrack) and go to step (a) to try other rows. 4) If all rows have been tried and nothing worked, return false to trigger backtracking.
  • 12. T H A N K Y O U ! A N Y Q U E S T I O N S ?

Editor's Notes

  • #4: No slide master