A Series of Slides in 5 Parts Movement 2. BFS

Slides:



Advertisements
Similar presentations
Breadth First Search AB F I EH DC G FIFO Queue - front.
Advertisements

AES Sub-Key Generation By Muhammad Naseem. Rotate Word 09CF4F3C.
Selinger Optimizer Lecture 10 October 15, 2009 Sam Madden.
State Space 3 Chapter 4 Heuristic Search. Three Algorithms Backtrack Depth First Breadth First All work if we have well-defined: Goal state Start state.
Row 1 Row 6 Row 5 Row 2 Row 7 Row 3 Row 8 Row 4 Row 9 Row 10 Row 11.
Combinations and Probability
CPSC-608 Database Systems Fall 2010 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes #9.
Multi-Method Dispatch Using Multiple Row Displacement Candy Pang, Wade Holst, Yuri Leontiev, and Duane Szafron ECOOP’99 Presented by: Irene Cheng Date:
So, let’s count in base 6 Digits allowed: 0, 1, 2, 3, 4, 5
Traveling Salesman Problems Repetitive Nearest-Neighbor and Cheapest-Link Algorithms Chapter: 6.
A forest of trees even with modest numbers of tip species, the number of possible trees is frightening. Fitch W.M Syst. Zool. 20:
CPSC-608 Database Systems Fall 2011 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes #8.
Quantitative Methods Designing experiments - keeping it simple.
Combinations & Permutations. Essentials: Permutations & Combinations (So that’s how we determine the number of possible samples!) Definitions: Permutation;
1 Algorithms CSCI 235, Fall 2012 Lecture 9 Probability.
Graph Partitioning Problem Kernighan and Lin Algorithm
CSE373: Data Structures & Algorithms Lecture 10: Disjoint Sets and the Union-Find ADT Lauren Milne Spring 2015.
6.3Find Probabilities Using Combinations
Find Probabilities Using Combinations
Computing the chromatic number for block intersection graphs of Latin squares Ed Sykes CS 721 project McMaster University, December 2004 Slide 1.
Phrase-structure grammar A phrase-structure grammar is a quadruple G = (V, T, P, S) where V is a finite set of symbols called nonterminals, T is a set.
TRANSITIVE PROPERTY of CONGRUENCE and EQUALITY GEO125 TRANSITIVE PROPERTY of EQUALITY: if a = b and b = c, then a = c. If = 9 and = 9, then.
Chapter 11 – Counting Methods Intro to Counting Methods Section 11.1: Counting by Systematic Listing.
AES Encryption FIPS 197, November 26, Bit Block Encryption Key Lengths 128, 192, 256 Number of Rounds Key Length Rounds Block.
A horse race has the following horses running. How many different first, second and third place results are possible: Mushroom Pepper Sausage Tomato Onion.
An importer of Herbs and Spices claims that average weight of packets of Saffron is 20 grams. However packets are actually filled to an average weight,
1 Chapter 6 Simplification of CFGs and Normal Forms.
CSE373: Data Structures & Algorithms Lecture 9: Disjoint Sets and the Union-Find ADT Lauren Milne Summer 2015.
A Valentines Day Problem Source The teachers lab Patterns in Mathematics
Geometry: Plane Figures Chapter. point A point marks a location. A A B B line segment the part of the line between 2 points endpoints.
Counting Techniques Tree Diagram Multiplication Rule Permutations Combinations.
Permutations and Combinations. Fundamental Counting Principle If there are r ways of performing one operation, s ways of performing a second operation,
南亚和印度.
Shortest Path -Prim’s -Djikstra’s. PRIM’s - Minimum Spanning Tree -A spanning tree of a graph is a tree that has all the vertices of the graph connected.
Learning from Bare Bones
Elementary Probability Theory
Programming Abstractions
The Polar Environmental Centre
Oil-soluble yellow pigment extracted from turmeric powder
The Fertile Crescent CCCS: A.2.a, A.2.b, A.2.c, B.2.a, B.2.b, C.2.a, D.2.a, D.2.b, D.2.c, D.2.d,
  Circle of Fifths C major G major Bb major D major Eb major A major
Aim: Full House Grid: 9 Grid Play: Calculate answer & cross it off
Combinations COURSE 3 LESSON 11-3
Combinations & Permutations
CSE373: Data Structures & Algorithms Lecture 10: Disjoint Sets and the Union-Find ADT Linda Shapiro Spring 2016.
Make an Organized List and Simulate a Problem
تصنيف التفاعلات الكيميائية
Line, line segment and rays.
Probability Simple and Compound Probability
Arranging and Choosing
Single Source Shortest Paths Bellman-Ford Algorithm
Rotors and Secret-Key Encryption
Running example The 4-houses puzzle:
CSE373: Data Structures & Algorithms Lecture 9: Disjoint Sets & Union-Find Dan Grossman Fall 2013.
Shortest path algorithm
On Desk: Learning Log: HW: WS p. 144 & 149
Gene Switching and the Stability of Odorant Receptor Gene Choice
Splash Screen.
Combinations & Permutations
Splash Screen.
Algorithms: Design and Analysis
Section 1.3 Segments and Their Measures
Splash Screen.
Vectors (2).
If AD = 10, DC =6, and ED = 15, find DB.
A Series of Slides in 5 Parts Movement 4. Best-First
A Series of Slides in 5 Parts Movement 4. Best-First
A Series of Slides in 5 Parts Movement 1. DFS
A Series of Slides in 5 Parts Movement 3. IDFS
Male FBN-ARO-KO mice exhibit cognitive defects but normal locomotor activity and anxiety levels. Male FBN-ARO-KO mice exhibit cognitive defects but normal.
Presentation transcript:

A Series of Slides in 5 Parts Movement 2. BFS Maze Running in C Minor A Series of Slides in 5 Parts Movement 2. BFS

AT: AA QUEUE: AB We will mark the nodes as visited in order to be compliant with how the visualizer code works. No visit information is actually being stored.. KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: AB QUEUE: AA AC BB Note that we added AA to the queue. We could choose not to add the node we came from, but we are doing so anyhow to show that it will only slowdown the search. KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: AA QUEUE: AC BB AB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: AC QUEUE: BB AB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: BB QUEUE: AB AB BA CB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: AB QUEUE: AB BA AB CB AA AC BB Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: AB QUEUE: BA AB CB AA AC BB Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: BA QUEUE: AB CB AA AC BB Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: AB QUEUE: CB AA AC BB CB Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: CB QUEUE: AA AC BB AA CB DB Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: AA QUEUE: AC BB AA AC CB DB AB Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: AC QUEUE: BB AA AC BB CB DB AB BA DA Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

At this point, you should realize how inefficient BFS is without keeping visit information. However, you should also see that it would eventually reach the exit due to the queue data structure. We will now start over.

AT: AA QUEUE: AB For each node, we will keep track of the node that we first came from to reach that node. KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: AB QUEUE: AC BB Note that we did not add AA to the queue. This time, we do not add the node we came from. KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: AC QUEUE: BB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: BB QUEUE: BA CB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: BA QUEUE: CB CA KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: CB QUEUE: CA DB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: CA QUEUE: DB DA KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DB QUEUE: DA DA DC EB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DA QUEUE: DA DC EB DB This is an interesting situation. We add DB and not CA to the code since we know that we reached DB through CA. KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DA QUEUE: DC EB DB This is an interesting situation. We add DB and not CA to the code since we know that we reached DB through CA. KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DC QUEUE: EB DB CC KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: EB QUEUE: DB DB CC EA EC KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DB QUEUE: DB CC EA EC DA DC EB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DB QUEUE: CC EA EC DA DC EB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: CC QUEUE: EA EC DA DC EB BC CD KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: EA QUEUE: EC DA DC EB BC CD KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: EC QUEUE: DA DC EB DA BC CD ED KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DA QUEUE: DC EB DA DC BC CD ED DB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DC QUEUE: EB DA DC EB BC CD ED DB CC KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: EB QUEUE: DA DC EB BC CD ED DB CC EA EC KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DA QUEUE: DC EB BC CD ED DB CC EA EC KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DC QUEUE: EB BC CD ED DB CC EA EC KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: EB QUEUE: BC CD ED DB CC EA EC Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: BC QUEUE: CD ED DB CC EA EC BD Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: CD QUEUE: ED DB CC EA EC BD Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: ED QUEUE: DB CC EA EC DB BD DD Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: DB QUEUE: CC EA EC DB CC BD DD DA DC EB Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: CC QUEUE: EA EC DB CC EA BD DD DA DC EB BC CD Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: EA QUEUE: EC DB CC EA EC BD DD DA DC EB BC CD Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: EC QUEUE: DB CC EA EC BD DD DA DC EB BC CD ED Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: DB QUEUE: CC EA EC BD DD DA DC EB BC CD ED Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: CC QUEUE: EA EC BD DD DA DC EB BC CD ED Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: EA QUEUE: EC BD DD DA DC EB BC CD ED Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: EC QUEUE: BD DD DA DC EB BC CD ED Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: BD QUEUE: DD DA DC EB BC CD ED AD Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

AT: DD QUEUE: DA DC EB BC CD ED DA AD Nodes are taken in the order: UP, LEFT, DOWN, RIGHT KEY: GREEN – Start RED – Exit YELLOW – Visited

Wow, that was still really inefficient. What would happen if we kept track of the nodes we visited?

AT: AA QUEUE: AB For each node, we will keep track of the node that we first came from to reach that node. KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: AB QUEUE: AC BB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: AC QUEUE: BB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: BB QUEUE: BA CB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: BA QUEUE: CB CA KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: CB QUEUE: CA DB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: CA QUEUE: DB DA KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DB QUEUE: DA DA DC EB KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DA QUEUE: DA DC EB We still have the double DA effect occurring, but this time, we add no nodes to the queue since both neighbors of DA have already been visited. KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DA QUEUE: DC EB Ever have a feeling of déjà vu? KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DC QUEUE: EB CC KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: EB QUEUE: CC EA EC KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: CC QUEUE: EA EC BC CD KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: EA QUEUE: EC BC CD KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: EC QUEUE: BC CD ED KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: BC QUEUE: CD ED BD KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: CD QUEUE: ED BD KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: ED QUEUE: BD DD KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: BD QUEUE: DD AD KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

AT: DD QUEUE: AD KEY: GREEN – Start RED – Exit YELLOW – Visited Nodes are taken in the order: UP, LEFT, DOWN, RIGHT

That was better, wasn’t it That was better, wasn’t it? We still explored the same number of nodes in the maze but with less repetition. However, did we change the principle that BFS always finds the optimal path? The answer is no. Convince yourself as to why this is true.