SlideShare a Scribd company logo
1 of 5
Download to read offline
Eotvos Lorand University - ELTE
Faculty of Informatics
Artificial Intelligence
5th Homework
Johnnatan Messias P. Afonso
Professor - Tibor Gregorics
Budapest - Hungary
March 26, 2014
Contents
1 Introduction 1
2 DFS - Depth-First Search 1
3 Backtracking 1
4 The differences 2
5 Conclusion 2
6 References 2
List of Figures
1 Difference between DFS and Backtracking . . . . . . . . . . . . . . . 3
Program’s List
1 DFS Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Backtracking Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . 2
2
1 Introduction
The Computer Science solves a lot of daily problems in our lifes, one of them
is search problems. These problems sometimes are so hard to find a good solution
because is necessary study hard to comprehend the problem, modeling it and after
this propose a solution. In this homework, my goal is define and explain the differ-
ences between the algorithms DFS - Depth-First Search and Backtrancking. Firstly,
I will introduce these algorithms in the section 2 and 3 to DFS and Backtracking
respectively. In the section 4 I will show the differences between them. Finally, the
conclusion in the section 5.
2 DFS - Depth-First Search
The DFS is an algorithm for searching in a tree structure or graph. It explores
so far as possible before start the traversing with the other node. Unfortunately the
DFS algorithm is Brute-Force.
This algorithm uses the following strategy:
• The edges are explored from the v vertice most recently discovered that has
edges to explorer from it.
• When all the edges are explored so the algorithm return and go to the next
vertice dicovered.
• If there is no edges to the next vertice but if we have a vertice not explored so
the algorithm will run for it too.
• The algorithm will run until all the vertices are explored.
We can see the pseudo-code in the Program 1.
procedure DFS−i t e r a t i v e (G, v) :
l e t S be a stack
S . push (v)
while S i s not empty
5 v = S . pop ()
i f v i s not labeled as discovered :
label v as discovered
for a l l edges from v to w in G. adjacentEdges (v) do
S . push (w)
Program 1: DFS Pseudo-Code
3 Backtracking
The Backtracking, like explained in 4 is a modified DFS of a tree consisting
of all of the possible sequences that can be constructed from the problem set. In
Backtracking we perform a DFS traversal of this tree until we reach a node that
is non-viable or non-promising, at which point we prune the subtree rooted at this
node, and continue the DFS traversal of the tree.
This algorithm uses the following strategy:
1
• Similar to DFS
• The Solution is a vector, each variable of a finite field
• At each step, defines the next variable to explore and values.
• Disconsider infeasible partial solutions
We can see the pseudo-code in the Program 2.
procedure bt ( c )
i f r e j e c t (P, c ) then return
i f accept (P, c ) then output (P, c )
s = f i r s t (P, c )
5 while s <> null do
bt ( s )
s = next (P, s )
Program 2: Backtracking Pseudo-Code
4 The differences
In the sections 2 and 3 we understood how the DFS and Backtracking algorithms
work. We saw how Backtracking is better than DFS, but what are the differences
between them? The reason that Backtracking is better than DFS is due to the first
one disconsider infeasible partial solutions therefore will be executed and return a
solution very faster than the second one.
Example by 5: The search space of a sorted list <5, 2, 4> would include all
3! permutations of solutions, as in the one at left below. The one at right shows
only those necessary to be examined to determine which permutation is the sorted
(descending) solution, <5, 4, 2.
In the Figure 1 we can see an example about the explored tree with these algo-
rithms.
5 Conclusion
In Computer Science we have a lot of solutions for the same problem, a lot
of algorithms to solve them. Although the Backtracking is better than DFS your
worst case is the same of the DFS therefore we always need to check the input of
the problem. I mean the Backtracking is better for which input? This information
is important because we need to check our problem before try to find a solution for
it.
6 References
1. Algoritimos - Teoria e Pratica, 2nd edition, Thomas H.Cormen
2. http://en.wikipedia.org/wiki/Depth-first_search
3. https://www.princeton.edu/~achaney/tmve/wiki100k/docs/Depth-first_
search.html
2
(a) DFS (b) Backtracking
Figure 1: Difference between DFS and Backtracking
4. http://www.academic.marist.edu/~jzbv/algorithms/Backtracking.htm
5. http://homepages.ius.edu/RWISMAN/C455/html/notes/Backtracking/Backtracking.
htm
3

More Related Content

What's hot

DB2 LUW - Backup and Recovery
DB2 LUW - Backup and RecoveryDB2 LUW - Backup and Recovery
DB2 LUW - Backup and Recoveryimranasayed
 
K19 k51-design-patterns-em-java
K19 k51-design-patterns-em-javaK19 k51-design-patterns-em-java
K19 k51-design-patterns-em-javaCaique Moretto
 
NoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenNoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenLorenzo Alberton
 
Bilgisayar Mimarisi 02, Feza BUZLUCA
Bilgisayar Mimarisi 02, Feza BUZLUCABilgisayar Mimarisi 02, Feza BUZLUCA
Bilgisayar Mimarisi 02, Feza BUZLUCAFeza BUZLUCA
 
Introducción a base de datos Oracle
Introducción a base de datos OracleIntroducción a base de datos Oracle
Introducción a base de datos Oraclepajaro5
 
Slides for In-Datacenter Performance Analysis of a Tensor Processing Unit
Slides for In-Datacenter Performance Analysis of a Tensor Processing UnitSlides for In-Datacenter Performance Analysis of a Tensor Processing Unit
Slides for In-Datacenter Performance Analysis of a Tensor Processing UnitCarlo C. del Mundo
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuningJugal Shah
 
Árvores Balanceadas AVL
Árvores Balanceadas AVLÁrvores Balanceadas AVL
Árvores Balanceadas AVLDaniel Maia
 
Cics testing and debugging-session 7
Cics testing and debugging-session 7Cics testing and debugging-session 7
Cics testing and debugging-session 7Srinimf-Slides
 
Bilgisayar Mimarisi 06, Feza BUZLUCA
Bilgisayar Mimarisi 06, Feza BUZLUCABilgisayar Mimarisi 06, Feza BUZLUCA
Bilgisayar Mimarisi 06, Feza BUZLUCAFeza BUZLUCA
 
Engenharia Dirigida por Modelos no Desenvolvimento de Aplicações Ubíquas: Tec...
Engenharia Dirigida por Modelos no Desenvolvimento de Aplicações Ubíquas: Tec...Engenharia Dirigida por Modelos no Desenvolvimento de Aplicações Ubíquas: Tec...
Engenharia Dirigida por Modelos no Desenvolvimento de Aplicações Ubíquas: Tec...Marcos Alves Vieira
 
Graphical Utilities For IBM DB2 Monitoring
Graphical Utilities For IBM DB2 MonitoringGraphical Utilities For IBM DB2 Monitoring
Graphical Utilities For IBM DB2 Monitoringluciano_alfonsin
 
Classification of debuggers sp
Classification of debuggers spClassification of debuggers sp
Classification of debuggers spShaishavShah8
 
M2 Introdução Basica ao Mainframe
M2 Introdução Basica ao MainframeM2 Introdução Basica ao Mainframe
M2 Introdução Basica ao Mainframemaldelrey
 

What's hot (20)

Dlm ppt
Dlm pptDlm ppt
Dlm ppt
 
DB2 LUW - Backup and Recovery
DB2 LUW - Backup and RecoveryDB2 LUW - Backup and Recovery
DB2 LUW - Backup and Recovery
 
Matlab module
Matlab moduleMatlab module
Matlab module
 
K19 k51-design-patterns-em-java
K19 k51-design-patterns-em-javaK19 k51-design-patterns-em-java
K19 k51-design-patterns-em-java
 
NoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenNoSQL Databases: Why, what and when
NoSQL Databases: Why, what and when
 
Basic Computer 208 part 2
Basic Computer 208 part 2 Basic Computer 208 part 2
Basic Computer 208 part 2
 
Bilgisayar Mimarisi 02, Feza BUZLUCA
Bilgisayar Mimarisi 02, Feza BUZLUCABilgisayar Mimarisi 02, Feza BUZLUCA
Bilgisayar Mimarisi 02, Feza BUZLUCA
 
Introducción a base de datos Oracle
Introducción a base de datos OracleIntroducción a base de datos Oracle
Introducción a base de datos Oracle
 
Slides for In-Datacenter Performance Analysis of a Tensor Processing Unit
Slides for In-Datacenter Performance Analysis of a Tensor Processing UnitSlides for In-Datacenter Performance Analysis of a Tensor Processing Unit
Slides for In-Datacenter Performance Analysis of a Tensor Processing Unit
 
Dblc
DblcDblc
Dblc
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
Lab 07-sol
Lab 07-solLab 07-sol
Lab 07-sol
 
Árvores Balanceadas AVL
Árvores Balanceadas AVLÁrvores Balanceadas AVL
Árvores Balanceadas AVL
 
Cics testing and debugging-session 7
Cics testing and debugging-session 7Cics testing and debugging-session 7
Cics testing and debugging-session 7
 
Bilgisayar Mimarisi 06, Feza BUZLUCA
Bilgisayar Mimarisi 06, Feza BUZLUCABilgisayar Mimarisi 06, Feza BUZLUCA
Bilgisayar Mimarisi 06, Feza BUZLUCA
 
Engenharia Dirigida por Modelos no Desenvolvimento de Aplicações Ubíquas: Tec...
Engenharia Dirigida por Modelos no Desenvolvimento de Aplicações Ubíquas: Tec...Engenharia Dirigida por Modelos no Desenvolvimento de Aplicações Ubíquas: Tec...
Engenharia Dirigida por Modelos no Desenvolvimento de Aplicações Ubíquas: Tec...
 
Zasady konfiguracji zestawów komputerowych
Zasady konfiguracji zestawów komputerowychZasady konfiguracji zestawów komputerowych
Zasady konfiguracji zestawów komputerowych
 
Graphical Utilities For IBM DB2 Monitoring
Graphical Utilities For IBM DB2 MonitoringGraphical Utilities For IBM DB2 Monitoring
Graphical Utilities For IBM DB2 Monitoring
 
Classification of debuggers sp
Classification of debuggers spClassification of debuggers sp
Classification of debuggers sp
 
M2 Introdução Basica ao Mainframe
M2 Introdução Basica ao MainframeM2 Introdução Basica ao Mainframe
M2 Introdução Basica ao Mainframe
 

Viewers also liked

Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...Fernando Rodrigues Junior
 
Depth first search and breadth first searching
Depth first search and breadth first searchingDepth first search and breadth first searching
Depth first search and breadth first searchingKawsar Hamid Sumon
 
Bfs and dfs in data structure
Bfs and dfs in  data structure Bfs and dfs in  data structure
Bfs and dfs in data structure Ankit Kumar Singh
 
(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 aiRadhika Srinivasan
 
Análise de Disco, I/O e Processamento
Análise de Disco, I/O e ProcessamentoAnálise de Disco, I/O e Processamento
Análise de Disco, I/O e ProcessamentoJohnnatan Messias
 
Caminhos Mínimos: Dijkstra e Floyd-Warshall
Caminhos Mínimos: Dijkstra e Floyd-WarshallCaminhos Mínimos: Dijkstra e Floyd-Warshall
Caminhos Mínimos: Dijkstra e Floyd-WarshallJohnnatan Messias
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligenceUmesh Meher
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtrackingmandlapure
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back trackingTech_MX
 
backtracking algorithms of ada
backtracking algorithms of adabacktracking algorithms of ada
backtracking algorithms of adaSahil Kumar
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}FellowBuddy.com
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchchandsek666
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentationAlizay Khan
 
Cálculo Numérico: Integração Numérica com Bubble Sort
Cálculo Numérico: Integração Numérica com Bubble SortCálculo Numérico: Integração Numérica com Bubble Sort
Cálculo Numérico: Integração Numérica com Bubble SortJohnnatan Messias
 
Twitter and Youtube Collector
Twitter and Youtube CollectorTwitter and Youtube Collector
Twitter and Youtube CollectorJohnnatan Messias
 
Avaliação de Usabilidade, Comunicabilidade e Acessibilidade - Quadro de Avisos
Avaliação de Usabilidade, Comunicabilidade e Acessibilidade - Quadro de AvisosAvaliação de Usabilidade, Comunicabilidade e Acessibilidade - Quadro de Avisos
Avaliação de Usabilidade, Comunicabilidade e Acessibilidade - Quadro de AvisosJohnnatan Messias
 
Análise de Algoritmos - Conceitos de Grafos
Análise de Algoritmos - Conceitos de GrafosAnálise de Algoritmos - Conceitos de Grafos
Análise de Algoritmos - Conceitos de GrafosDelacyr Ferreira
 

Viewers also liked (20)

Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
 
Depth first search and breadth first searching
Depth first search and breadth first searchingDepth first search and breadth first searching
Depth first search and breadth first searching
 
Bfs and dfs in data structure
Bfs and dfs in  data structure Bfs and dfs in  data structure
Bfs and dfs in data structure
 
(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai
 
Análise de Disco, I/O e Processamento
Análise de Disco, I/O e ProcessamentoAnálise de Disco, I/O e Processamento
Análise de Disco, I/O e Processamento
 
Caminhos Mínimos: Dijkstra e Floyd-Warshall
Caminhos Mínimos: Dijkstra e Floyd-WarshallCaminhos Mínimos: Dijkstra e Floyd-Warshall
Caminhos Mínimos: Dijkstra e Floyd-Warshall
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtracking
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 
backtracking algorithms of ada
backtracking algorithms of adabacktracking algorithms of ada
backtracking algorithms of ada
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) search
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentation
 
Minesweeper
MinesweeperMinesweeper
Minesweeper
 
Cálculo Numérico: Integração Numérica com Bubble Sort
Cálculo Numérico: Integração Numérica com Bubble SortCálculo Numérico: Integração Numérica com Bubble Sort
Cálculo Numérico: Integração Numérica com Bubble Sort
 
MyShell
MyShellMyShell
MyShell
 
MyShell - English
MyShell - EnglishMyShell - English
MyShell - English
 
Twitter and Youtube Collector
Twitter and Youtube CollectorTwitter and Youtube Collector
Twitter and Youtube Collector
 
Avaliação de Usabilidade, Comunicabilidade e Acessibilidade - Quadro de Avisos
Avaliação de Usabilidade, Comunicabilidade e Acessibilidade - Quadro de AvisosAvaliação de Usabilidade, Comunicabilidade e Acessibilidade - Quadro de Avisos
Avaliação de Usabilidade, Comunicabilidade e Acessibilidade - Quadro de Avisos
 
Análise de Algoritmos - Conceitos de Grafos
Análise de Algoritmos - Conceitos de GrafosAnálise de Algoritmos - Conceitos de Grafos
Análise de Algoritmos - Conceitos de Grafos
 

Similar to AI - Backtracking vs Depth-First Search (DFS)

Riya Bepari_34700122020_Artificial Intelligence_PEC-IT501B.pptx
Riya Bepari_34700122020_Artificial Intelligence_PEC-IT501B.pptxRiya Bepari_34700122020_Artificial Intelligence_PEC-IT501B.pptx
Riya Bepari_34700122020_Artificial Intelligence_PEC-IT501B.pptxRIYABEPARI
 
Self Stabilizing Depth-first Search
Self Stabilizing Depth-first SearchSelf Stabilizing Depth-first Search
Self Stabilizing Depth-first SearchIntan Dzikria
 
01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms Notes01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms NotesAndres Mendez-Vazquez
 
CSA 2001 (Module-2).pptx
CSA 2001 (Module-2).pptxCSA 2001 (Module-2).pptx
CSA 2001 (Module-2).pptxPranjalKhare13
 
Crash-course in Natural Language Processing
Crash-course in Natural Language ProcessingCrash-course in Natural Language Processing
Crash-course in Natural Language ProcessingVsevolod Dyomkin
 
Artificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxRatnakar Mikkili
 
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...DrkhanchanaR
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programmingJay Nagar
 
Advance data structure
Advance data structureAdvance data structure
Advance data structureashok kumar
 
Advanced data structures using c++ 3
Advanced data structures using c++ 3Advanced data structures using c++ 3
Advanced data structures using c++ 3Shaili Choudhary
 
Methodological study of opinion mining and sentiment analysis techniques
Methodological study of opinion mining and sentiment analysis techniquesMethodological study of opinion mining and sentiment analysis techniques
Methodological study of opinion mining and sentiment analysis techniquesijsc
 
A Robust Method Based On LOVO Functions For Solving Least Squares Problems
A Robust Method Based On LOVO Functions For Solving Least Squares ProblemsA Robust Method Based On LOVO Functions For Solving Least Squares Problems
A Robust Method Based On LOVO Functions For Solving Least Squares ProblemsDawn Cook
 

Similar to AI - Backtracking vs Depth-First Search (DFS) (20)

Riya Bepari_34700122020_Artificial Intelligence_PEC-IT501B.pptx
Riya Bepari_34700122020_Artificial Intelligence_PEC-IT501B.pptxRiya Bepari_34700122020_Artificial Intelligence_PEC-IT501B.pptx
Riya Bepari_34700122020_Artificial Intelligence_PEC-IT501B.pptx
 
Self Stabilizing Depth-first Search
Self Stabilizing Depth-first SearchSelf Stabilizing Depth-first Search
Self Stabilizing Depth-first Search
 
Parallel search
Parallel searchParallel search
Parallel search
 
01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms Notes01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms Notes
 
Adsa u2 ver 1.0.
Adsa u2 ver 1.0.Adsa u2 ver 1.0.
Adsa u2 ver 1.0.
 
dfs.pptx
dfs.pptxdfs.pptx
dfs.pptx
 
Parallel searching
Parallel searchingParallel searching
Parallel searching
 
CSA 2001 (Module-2).pptx
CSA 2001 (Module-2).pptxCSA 2001 (Module-2).pptx
CSA 2001 (Module-2).pptx
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
algorithm Unit 5
algorithm Unit 5 algorithm Unit 5
algorithm Unit 5
 
Crash-course in Natural Language Processing
Crash-course in Natural Language ProcessingCrash-course in Natural Language Processing
Crash-course in Natural Language Processing
 
Artificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptx
 
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Advance data structure
Advance data structureAdvance data structure
Advance data structure
 
Advanced data structures using c++ 3
Advanced data structures using c++ 3Advanced data structures using c++ 3
Advanced data structures using c++ 3
 
Methodological study of opinion mining and sentiment analysis techniques
Methodological study of opinion mining and sentiment analysis techniquesMethodological study of opinion mining and sentiment analysis techniques
Methodological study of opinion mining and sentiment analysis techniques
 
Branch and Bound.pptx
Branch and Bound.pptxBranch and Bound.pptx
Branch and Bound.pptx
 
A Robust Method Based On LOVO Functions For Solving Least Squares Problems
A Robust Method Based On LOVO Functions For Solving Least Squares ProblemsA Robust Method Based On LOVO Functions For Solving Least Squares Problems
A Robust Method Based On LOVO Functions For Solving Least Squares Problems
 

More from Johnnatan Messias

Monografia: Framework Para Sistemas de Navegação de Veículos Aéreos Não Tripu...
Monografia: Framework Para Sistemas de Navegação de Veículos Aéreos Não Tripu...Monografia: Framework Para Sistemas de Navegação de Veículos Aéreos Não Tripu...
Monografia: Framework Para Sistemas de Navegação de Veículos Aéreos Não Tripu...Johnnatan Messias
 
Cálculo Numérico: Interpolação Polinomial com Bubble Sort
Cálculo Numérico: Interpolação Polinomial com Bubble SortCálculo Numérico: Interpolação Polinomial com Bubble Sort
Cálculo Numérico: Interpolação Polinomial com Bubble SortJohnnatan Messias
 
Análise de Algoritmos de Ordenação Interna
Análise de Algoritmos de Ordenação InternaAnálise de Algoritmos de Ordenação Interna
Análise de Algoritmos de Ordenação InternaJohnnatan Messias
 

More from Johnnatan Messias (6)

Monografia: Framework Para Sistemas de Navegação de Veículos Aéreos Não Tripu...
Monografia: Framework Para Sistemas de Navegação de Veículos Aéreos Não Tripu...Monografia: Framework Para Sistemas de Navegação de Veículos Aéreos Não Tripu...
Monografia: Framework Para Sistemas de Navegação de Veículos Aéreos Não Tripu...
 
Quadro de Avisos - IHC
Quadro de Avisos - IHCQuadro de Avisos - IHC
Quadro de Avisos - IHC
 
Lista Encadeada - TP2_AEDSI
Lista Encadeada - TP2_AEDSILista Encadeada - TP2_AEDSI
Lista Encadeada - TP2_AEDSI
 
Simulador Funcional
Simulador FuncionalSimulador Funcional
Simulador Funcional
 
Cálculo Numérico: Interpolação Polinomial com Bubble Sort
Cálculo Numérico: Interpolação Polinomial com Bubble SortCálculo Numérico: Interpolação Polinomial com Bubble Sort
Cálculo Numérico: Interpolação Polinomial com Bubble Sort
 
Análise de Algoritmos de Ordenação Interna
Análise de Algoritmos de Ordenação InternaAnálise de Algoritmos de Ordenação Interna
Análise de Algoritmos de Ordenação Interna
 

Recently uploaded

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Recently uploaded (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

AI - Backtracking vs Depth-First Search (DFS)

  • 1. Eotvos Lorand University - ELTE Faculty of Informatics Artificial Intelligence 5th Homework Johnnatan Messias P. Afonso Professor - Tibor Gregorics Budapest - Hungary March 26, 2014
  • 2. Contents 1 Introduction 1 2 DFS - Depth-First Search 1 3 Backtracking 1 4 The differences 2 5 Conclusion 2 6 References 2 List of Figures 1 Difference between DFS and Backtracking . . . . . . . . . . . . . . . 3 Program’s List 1 DFS Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 Backtracking Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . 2 2
  • 3. 1 Introduction The Computer Science solves a lot of daily problems in our lifes, one of them is search problems. These problems sometimes are so hard to find a good solution because is necessary study hard to comprehend the problem, modeling it and after this propose a solution. In this homework, my goal is define and explain the differ- ences between the algorithms DFS - Depth-First Search and Backtrancking. Firstly, I will introduce these algorithms in the section 2 and 3 to DFS and Backtracking respectively. In the section 4 I will show the differences between them. Finally, the conclusion in the section 5. 2 DFS - Depth-First Search The DFS is an algorithm for searching in a tree structure or graph. It explores so far as possible before start the traversing with the other node. Unfortunately the DFS algorithm is Brute-Force. This algorithm uses the following strategy: • The edges are explored from the v vertice most recently discovered that has edges to explorer from it. • When all the edges are explored so the algorithm return and go to the next vertice dicovered. • If there is no edges to the next vertice but if we have a vertice not explored so the algorithm will run for it too. • The algorithm will run until all the vertices are explored. We can see the pseudo-code in the Program 1. procedure DFS−i t e r a t i v e (G, v) : l e t S be a stack S . push (v) while S i s not empty 5 v = S . pop () i f v i s not labeled as discovered : label v as discovered for a l l edges from v to w in G. adjacentEdges (v) do S . push (w) Program 1: DFS Pseudo-Code 3 Backtracking The Backtracking, like explained in 4 is a modified DFS of a tree consisting of all of the possible sequences that can be constructed from the problem set. In Backtracking we perform a DFS traversal of this tree until we reach a node that is non-viable or non-promising, at which point we prune the subtree rooted at this node, and continue the DFS traversal of the tree. This algorithm uses the following strategy: 1
  • 4. • Similar to DFS • The Solution is a vector, each variable of a finite field • At each step, defines the next variable to explore and values. • Disconsider infeasible partial solutions We can see the pseudo-code in the Program 2. procedure bt ( c ) i f r e j e c t (P, c ) then return i f accept (P, c ) then output (P, c ) s = f i r s t (P, c ) 5 while s <> null do bt ( s ) s = next (P, s ) Program 2: Backtracking Pseudo-Code 4 The differences In the sections 2 and 3 we understood how the DFS and Backtracking algorithms work. We saw how Backtracking is better than DFS, but what are the differences between them? The reason that Backtracking is better than DFS is due to the first one disconsider infeasible partial solutions therefore will be executed and return a solution very faster than the second one. Example by 5: The search space of a sorted list <5, 2, 4> would include all 3! permutations of solutions, as in the one at left below. The one at right shows only those necessary to be examined to determine which permutation is the sorted (descending) solution, <5, 4, 2. In the Figure 1 we can see an example about the explored tree with these algo- rithms. 5 Conclusion In Computer Science we have a lot of solutions for the same problem, a lot of algorithms to solve them. Although the Backtracking is better than DFS your worst case is the same of the DFS therefore we always need to check the input of the problem. I mean the Backtracking is better for which input? This information is important because we need to check our problem before try to find a solution for it. 6 References 1. Algoritimos - Teoria e Pratica, 2nd edition, Thomas H.Cormen 2. http://en.wikipedia.org/wiki/Depth-first_search 3. https://www.princeton.edu/~achaney/tmve/wiki100k/docs/Depth-first_ search.html 2
  • 5. (a) DFS (b) Backtracking Figure 1: Difference between DFS and Backtracking 4. http://www.academic.marist.edu/~jzbv/algorithms/Backtracking.htm 5. http://homepages.ius.edu/RWISMAN/C455/html/notes/Backtracking/Backtracking. htm 3