SlideShare a Scribd company logo
1 of 20
“MAZE” Problem
& its Solution
By-Mudit Dholakia(14MTPOS001-MT005)
Guide:-Prof.P.M.Jadav
What is ‘maze’?
• Maze means confusing in nature.
• A network of paths and hedges designed as a puzzle through which
one has to find a way.
• DAZED
What to do with computers?
• It is easy to understand for a matured person.
• But what if we solve it using computer.????
?
Instruct Computer
• Solution is to devise an algorithm for given maze.
DYNAMIC
EFFECTIVE
Available Approaches
• Dynamic Programming
• Backtracking
• Greedy Approach
Backtracking?!
• We will solve this problem using backtracking.
• The reason behind this is we have pre-defined constraints.
• Hence it facilitates some ease for the programmer to choose the best
solutions.
• It also avoids undesired computations.
Example
Expected Solution
• 11x22 matrix
• “0”->wall
• “1”->gap
• Source Position (8,15)
• Destination Position(10,18)
Thinking from programmer’s perspective
• Constraints are there
• Array (matrix) is there
• Exploration of the right path is to be done
• “IN GENERAL WE HAVE TO FIND A CLEAR PATH TOWARDS
DESTINATION”
• 1. Consider the VISITED node, if it is ‘eligible’ for exploration.
• 2.Move forward else ‘stop’.
Ideal Algorithm
• 1. Consider a diamond neighbourhood of the algorithm.(i.e.
immediate neighbours HORIZONTALY and VERTICALY)
• 2.If ‘eligible’ move ahead having a track of backward knowledge
• 3.Else if not end then find another neighbour and follow step 2.
• 4.else ‘stop’
Tree consideration
• If we consider this problem solution to be an application of the
traditional tree then it is clear that “DFS-Depth First Search” tree
algorithm can solve this.
• Because in DFS we maintain all the visited track globally and move
further. So that visit consistency and order can be preserved.
Check for safe position
• int isSafe(int x,int y,int G[V1][V2],int Sol[V1][V2]) /* to check the safe move */
• {
• if(x>=0 && x<V1 && y>=0&&y<V2 && G[x][y]==1 && !Sol[x][y])
• {
• return 1;
• }
• else
• {
• return 0;
• }
• }
int MazeRecur(int G[V1][V2], int Sol[V1][V2], int x,int y) /* checking for the path to our exit point */
{
if(x==er &&y==ec)
{
Sol[x][y]=1;
return 1;
}
if(isSafe(x,y,G,Sol)==1)
{
printf("->(%d,%d)->",x,y);
Sol[x][y]=1;
if(MazeRecur(G,Sol,x,y-1)==1) /* left move possible */
{
return 1;
}
if(MazeRecur(G,Sol,x,y+1)==1) /* right move possible */
{
return 1;
}
if(MazeRecur(G,Sol,x-1,y)==1) /* up move possible */
{
return 1;
}
if(MazeRecur(G,Sol,x+1,y)==1) /* down move possible */
{
return 1;
}
Sol[x][y]=0;
}
return 0;
}
Immediate Neighbours
Implementing through C language
Time Complexity
• Consider only depth first search
of nodes.
• For mxn matrix to iterate the
search of node it will take
T(n*m/2) in worst case.
• And we add DFS recursive
backtrack algorithm time
T(n)=4T(n-1) for the 4 immediate
neighbours.
• T(n)=4T(nxm)
• Using master’s theorem it will
take 4 𝑛∗𝑚 exponential time.
• If we use backtracking then it
can be reduced to 2 𝑛∗𝑚
.
Improved algorithm can be designed …
• Using stack
• Using some enumerated datatypes
• Using K-connected neighbourhood concept
• Indexed data structures
References
• http://www.geeksforgeeks.org/backttracking-set-2-rat-in-a-maze/
• http://en.wikipedia.org/wiki/Maze_solving_algorithm
• https://www.cs.bu.edu/teaching/alg/maze/
• http://techlanguageworld.blogspot.in/2014/02/c-program-to-solve-
maze-problem.html
Queries?
THANK YOU

More Related Content

What's hot

Monkey & banana problem in AI
Monkey & banana problem in AIMonkey & banana problem in AI
Monkey & banana problem in AIManjeet Kamboj
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}FellowBuddy.com
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic ProgrammingSahil Kumar
 
L03 ai - knowledge representation using logic
L03 ai - knowledge representation using logicL03 ai - knowledge representation using logic
L03 ai - knowledge representation using logicManjula V
 
Coin change Problem (DP & GREEDY)
Coin change Problem (DP & GREEDY)Coin change Problem (DP & GREEDY)
Coin change Problem (DP & GREEDY)Ridhima Chowdhury
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programmingTafhim Islam
 
Genetic algorithms vs Traditional algorithms
Genetic algorithms vs Traditional algorithmsGenetic algorithms vs Traditional algorithms
Genetic algorithms vs Traditional algorithmsDr. C.V. Suresh Babu
 
Adversarial search
Adversarial searchAdversarial search
Adversarial searchNilu Desai
 
Travelling SalesMan Problem(TSP)
Travelling SalesMan Problem(TSP)Travelling SalesMan Problem(TSP)
Travelling SalesMan Problem(TSP)Akshay Kamble
 
Genetic algorithm ppt
Genetic algorithm pptGenetic algorithm ppt
Genetic algorithm pptMayank Jain
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptProblem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptarunsingh660
 

What's hot (20)

Prim's algorithm
Prim's algorithmPrim's algorithm
Prim's algorithm
 
Maximum flow
Maximum flowMaximum flow
Maximum flow
 
Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
 
Monkey & banana problem in AI
Monkey & banana problem in AIMonkey & banana problem in AI
Monkey & banana problem in AI
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Hill climbing algorithm
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
 
Backtracking
Backtracking  Backtracking
Backtracking
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
L03 ai - knowledge representation using logic
L03 ai - knowledge representation using logicL03 ai - knowledge representation using logic
L03 ai - knowledge representation using logic
 
Coin change Problem (DP & GREEDY)
Coin change Problem (DP & GREEDY)Coin change Problem (DP & GREEDY)
Coin change Problem (DP & GREEDY)
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programming
 
Genetic algorithms vs Traditional algorithms
Genetic algorithms vs Traditional algorithmsGenetic algorithms vs Traditional algorithms
Genetic algorithms vs Traditional algorithms
 
Evolutionary Computing
Evolutionary ComputingEvolutionary Computing
Evolutionary Computing
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
Daa
DaaDaa
Daa
 
Travelling SalesMan Problem(TSP)
Travelling SalesMan Problem(TSP)Travelling SalesMan Problem(TSP)
Travelling SalesMan Problem(TSP)
 
Genetic algorithm ppt
Genetic algorithm pptGenetic algorithm ppt
Genetic algorithm ppt
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptProblem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.ppt
 
Informed search
Informed searchInformed search
Informed search
 

Viewers also liked

Maze solving quad_rotor
Maze solving quad_rotorMaze solving quad_rotor
Maze solving quad_rotornguyendattdh
 
08 recursive backtracking
08 recursive backtracking08 recursive backtracking
08 recursive backtrackingOmar Shahid
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen ProblemSukrit Gupta
 
Presentation of 3rd Semester C++ Project
Presentation of 3rd Semester C++ ProjectPresentation of 3rd Semester C++ Project
Presentation of 3rd Semester C++ ProjectChandan Gupta Bhagat
 
16890 unit 2 heuristic search techniques
16890 unit 2 heuristic  search techniques16890 unit 2 heuristic  search techniques
16890 unit 2 heuristic search techniquesJais Balta
 
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
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesFahim Ferdous
 
Graph data structure
Graph data structureGraph data structure
Graph data structureTech_MX
 

Viewers also liked (9)

Maze solving quad_rotor
Maze solving quad_rotorMaze solving quad_rotor
Maze solving quad_rotor
 
08 recursive backtracking
08 recursive backtracking08 recursive backtracking
08 recursive backtracking
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen Problem
 
Presentation of 3rd Semester C++ Project
Presentation of 3rd Semester C++ ProjectPresentation of 3rd Semester C++ Project
Presentation of 3rd Semester C++ Project
 
16890 unit 2 heuristic search techniques
16890 unit 2 heuristic  search techniques16890 unit 2 heuristic  search techniques
16890 unit 2 heuristic search techniques
 
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 ...
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
 
Graph data structure
Graph data structureGraph data structure
Graph data structure
 
Backtracking
BacktrackingBacktracking
Backtracking
 

Similar to Maze Problem Presentation

"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)Tech in Asia ID
 
Yoyak ScalaDays 2015
Yoyak ScalaDays 2015Yoyak ScalaDays 2015
Yoyak ScalaDays 2015ihji
 
Machine Learning on Azure - AzureConf
Machine Learning on Azure - AzureConfMachine Learning on Azure - AzureConf
Machine Learning on Azure - AzureConfSeth Juarez
 
Lucio marcenaro tue summer_school
Lucio marcenaro tue summer_schoolLucio marcenaro tue summer_school
Lucio marcenaro tue summer_schoolJun Hu
 
(CMP305) Deep Learning on AWS Made EasyCmp305
(CMP305) Deep Learning on AWS Made EasyCmp305(CMP305) Deep Learning on AWS Made EasyCmp305
(CMP305) Deep Learning on AWS Made EasyCmp305Amazon Web Services
 
mini project_shortest path visualizer.pptx
mini project_shortest path visualizer.pptxmini project_shortest path visualizer.pptx
mini project_shortest path visualizer.pptxtusharpawar803067
 
EnrichmentWeek Binus Computer Vision
EnrichmentWeek Binus Computer VisionEnrichmentWeek Binus Computer Vision
EnrichmentWeek Binus Computer Visiongiamuhammad
 
LECTURE 7 REVIEW, EXCEPTIONS, IO.pdf
LECTURE 7 REVIEW, EXCEPTIONS, IO.pdfLECTURE 7 REVIEW, EXCEPTIONS, IO.pdf
LECTURE 7 REVIEW, EXCEPTIONS, IO.pdfShashikantSathe3
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaoladrewz lin
 
Build tic tac toe with javascript (4:11 dc)
Build tic tac toe with javascript (4:11 dc)Build tic tac toe with javascript (4:11 dc)
Build tic tac toe with javascript (4:11 dc)Daniel Friedman
 
Introduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous AgentsIntroduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous AgentsBryan Duggan
 
Understanding Basics of Machine Learning
Understanding Basics of Machine LearningUnderstanding Basics of Machine Learning
Understanding Basics of Machine LearningPranav Ainavolu
 
Automated Design Validation The Solid Works Api
Automated Design Validation The Solid Works ApiAutomated Design Validation The Solid Works Api
Automated Design Validation The Solid Works ApiRazorleaf Corporation
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxRaviKiranVarma4
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Fwdays
 

Similar to Maze Problem Presentation (20)

"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
 
chapter3part1.ppt
chapter3part1.pptchapter3part1.ppt
chapter3part1.ppt
 
Yoyak ScalaDays 2015
Yoyak ScalaDays 2015Yoyak ScalaDays 2015
Yoyak ScalaDays 2015
 
Machine Learning on Azure - AzureConf
Machine Learning on Azure - AzureConfMachine Learning on Azure - AzureConf
Machine Learning on Azure - AzureConf
 
Lucio marcenaro tue summer_school
Lucio marcenaro tue summer_schoolLucio marcenaro tue summer_school
Lucio marcenaro tue summer_school
 
(CMP305) Deep Learning on AWS Made EasyCmp305
(CMP305) Deep Learning on AWS Made EasyCmp305(CMP305) Deep Learning on AWS Made EasyCmp305
(CMP305) Deep Learning on AWS Made EasyCmp305
 
mini project_shortest path visualizer.pptx
mini project_shortest path visualizer.pptxmini project_shortest path visualizer.pptx
mini project_shortest path visualizer.pptx
 
EnrichmentWeek Binus Computer Vision
EnrichmentWeek Binus Computer VisionEnrichmentWeek Binus Computer Vision
EnrichmentWeek Binus Computer Vision
 
LECTURE 7 REVIEW, EXCEPTIONS, IO.pdf
LECTURE 7 REVIEW, EXCEPTIONS, IO.pdfLECTURE 7 REVIEW, EXCEPTIONS, IO.pdf
LECTURE 7 REVIEW, EXCEPTIONS, IO.pdf
 
Java Tutorial
Java Tutorial Java Tutorial
Java Tutorial
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaola
 
RSA ALGORITHM
RSA ALGORITHMRSA ALGORITHM
RSA ALGORITHM
 
Tutorial matlab
Tutorial matlabTutorial matlab
Tutorial matlab
 
Tutorialmatlab kurniawan.s
Tutorialmatlab kurniawan.sTutorialmatlab kurniawan.s
Tutorialmatlab kurniawan.s
 
Build tic tac toe with javascript (4:11 dc)
Build tic tac toe with javascript (4:11 dc)Build tic tac toe with javascript (4:11 dc)
Build tic tac toe with javascript (4:11 dc)
 
Introduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous AgentsIntroduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous Agents
 
Understanding Basics of Machine Learning
Understanding Basics of Machine LearningUnderstanding Basics of Machine Learning
Understanding Basics of Machine Learning
 
Automated Design Validation The Solid Works Api
Automated Design Validation The Solid Works ApiAutomated Design Validation The Solid Works Api
Automated Design Validation The Solid Works Api
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
 

Recently uploaded

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....rightmanforbloodline
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseWSO2
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 

Recently uploaded (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 

Maze Problem Presentation

  • 1. “MAZE” Problem & its Solution By-Mudit Dholakia(14MTPOS001-MT005) Guide:-Prof.P.M.Jadav
  • 2. What is ‘maze’? • Maze means confusing in nature. • A network of paths and hedges designed as a puzzle through which one has to find a way. • DAZED
  • 3. What to do with computers? • It is easy to understand for a matured person. • But what if we solve it using computer.???? ?
  • 4. Instruct Computer • Solution is to devise an algorithm for given maze. DYNAMIC EFFECTIVE
  • 5. Available Approaches • Dynamic Programming • Backtracking • Greedy Approach
  • 6. Backtracking?! • We will solve this problem using backtracking. • The reason behind this is we have pre-defined constraints. • Hence it facilitates some ease for the programmer to choose the best solutions. • It also avoids undesired computations.
  • 8. Expected Solution • 11x22 matrix • “0”->wall • “1”->gap • Source Position (8,15) • Destination Position(10,18)
  • 9. Thinking from programmer’s perspective • Constraints are there • Array (matrix) is there • Exploration of the right path is to be done • “IN GENERAL WE HAVE TO FIND A CLEAR PATH TOWARDS DESTINATION” • 1. Consider the VISITED node, if it is ‘eligible’ for exploration. • 2.Move forward else ‘stop’.
  • 10. Ideal Algorithm • 1. Consider a diamond neighbourhood of the algorithm.(i.e. immediate neighbours HORIZONTALY and VERTICALY) • 2.If ‘eligible’ move ahead having a track of backward knowledge • 3.Else if not end then find another neighbour and follow step 2. • 4.else ‘stop’
  • 11. Tree consideration • If we consider this problem solution to be an application of the traditional tree then it is clear that “DFS-Depth First Search” tree algorithm can solve this. • Because in DFS we maintain all the visited track globally and move further. So that visit consistency and order can be preserved.
  • 12. Check for safe position • int isSafe(int x,int y,int G[V1][V2],int Sol[V1][V2]) /* to check the safe move */ • { • if(x>=0 && x<V1 && y>=0&&y<V2 && G[x][y]==1 && !Sol[x][y]) • { • return 1; • } • else • { • return 0; • } • }
  • 13. int MazeRecur(int G[V1][V2], int Sol[V1][V2], int x,int y) /* checking for the path to our exit point */ { if(x==er &&y==ec) { Sol[x][y]=1; return 1; } if(isSafe(x,y,G,Sol)==1) { printf("->(%d,%d)->",x,y); Sol[x][y]=1; if(MazeRecur(G,Sol,x,y-1)==1) /* left move possible */ { return 1; } if(MazeRecur(G,Sol,x,y+1)==1) /* right move possible */ { return 1; } if(MazeRecur(G,Sol,x-1,y)==1) /* up move possible */ { return 1; } if(MazeRecur(G,Sol,x+1,y)==1) /* down move possible */ { return 1; } Sol[x][y]=0; } return 0; }
  • 16. Time Complexity • Consider only depth first search of nodes. • For mxn matrix to iterate the search of node it will take T(n*m/2) in worst case. • And we add DFS recursive backtrack algorithm time T(n)=4T(n-1) for the 4 immediate neighbours. • T(n)=4T(nxm) • Using master’s theorem it will take 4 𝑛∗𝑚 exponential time. • If we use backtracking then it can be reduced to 2 𝑛∗𝑚 .
  • 17. Improved algorithm can be designed … • Using stack • Using some enumerated datatypes • Using K-connected neighbourhood concept • Indexed data structures
  • 18. References • http://www.geeksforgeeks.org/backttracking-set-2-rat-in-a-maze/ • http://en.wikipedia.org/wiki/Maze_solving_algorithm • https://www.cs.bu.edu/teaching/alg/maze/ • http://techlanguageworld.blogspot.in/2014/02/c-program-to-solve- maze-problem.html