information of the lo subject: data structures, algorithms topic: maze routing education level: ug...
TRANSCRIPT
Information of the LO
Subject: Data Structures, Algorithms
Topic: Maze Routing
Education Level: UG
Problem Statement:Given a n x n maze, find a path from start to finish by moving either horizontally
or vertically without going through the walls.
Authors: Mentor: Jasveer Singh T. Jethra Prof. Sachin PatkarPriyadarshan H
1
Pre requisites
Before using this LO, the user should know about the following:
No prerequisites
2
Learning objectives
After interacting with this LO the user should be able to:
• Find a path in a maze from start to finish.
3
Keywords in this LOThese are the keywords and their description in this LO
1. Live Node:This is a node which has been traversed and all possible ways of expansion have not been explored.
2. E-node:E-node or Expansion Node is the current node from which we explore for possible empty nodes in the neighbourhood. There is only one E-node at any instant.
3. Dead Node:If we leave a E-node from the direction in which this node was entered then it becomes a dead node. This node is to be treated as a wall in future.
4. Wall:It is a node (block) which cannot be entered.
4
5. Empty Node:This is a node which is available for traversal.
6. Start Node:It is the node from which we start traversing the maze. This node can never be a wall.
7. Finish Node:It is a node where we intend to reach. This node can never be a wall.
5
Element groups in this LOS. No. Name of the element group and
AbbreviationName of the
elements in the group
Rank of element group (in terms of the most important element group on the screen that students should focus on) 1: most
important, 2: next in importance, … and so on
1 Maze 1
2 Screen text2
(Will not be available for Interactivity part)
3 Interactivity Block2
(Will not be available for Demo part)
4 Legend 3
6
Element groups in this LO – Sample template of LO
7
MazeOn screen
text/Interactivity block
Legend
Write the name of the element group 1 - MazeThe title of each column explains contains guidelines on the details required.)
8
Name of the element
Abbreviation Reference image
Image for
using in LO
Functional or interactivity details
Connected to
Maze Explained in next slide
Wall #
Maze is made of these blocks.
Empty Block #
Live node #
Expansion node E-node #
Dead node #
Start Node #
Finish Node #
# Refer Keywords slide No. 4
Start
Finish
Functionality of Maze
9
It is a square area of n x n blocks with walls on the four sides of the boundary and walls at some places within the n x n area. In the square area excluding the walls, the (1,1) block represents the start node and (n,n) block represents the finish node. These blocks are always empty.The figure in slide no. 13 shows a maze with all empty blocks surrounded by walls.The fig in slide no. 17 shows a maze with walls within.
Write the name of the element group 3 - InteractivityThe title of each column explains contains guidelines on the details required.)
10
Name of the element Abbreviation
Reference image
Image for using in LO
Functional or interactivity details
Wall Style
Dropdown box1.Default2.Predefined path3.No path(Refer next slide for functionality of wall styles)
Find path
ButtonIf a user clicks on the find path button, the algorithm starts executing.(For example of operation refer slides 15 to 42)
Functionality of Wall styles
11
1. Default: When user selects this style, the animator can choose any maze of n x n size which should be legibly displayable on the screen with the only constraint that there should not be any walls in the interior of the wall.
2. Predefined Path:When user selects this style, the animator can choose any maze of n x n size which should be legibly displayable on the screen with the only constraint that there should exist a path from start to finish. For instance, see the maze shown in slide no. 17.
3. No Path:When user selects this style, the animator can choose any maze of n x n size which should be legibly displayable on the screen with the only constraint that there should NOT exist any path from start to finish. For instance, in any maze surround the Finish Node with walls.
Write the name of the element group 4 - LegendThe title of each column explains contains guidelines on the details required.)
12
Start
Finish
Wall
Empty Node
Live Node
Expansion Node (E-node)
Dead Node
Start Node
Finish Node
Legend:
Interactivity (for both Demo and Interactivity part):When the user places the mouse pointer on top of any of the legend objects, popup a message which defines that particular object. Use the definition as given in the Keywords (Refer Slide no. 4). For instance, if the user places his mouse pointer on “Wall” object, then popup “It is a node (block) which cannot be entered”.
Supportive image for step 1
13
Start
Finish
Step 1
14
S. No.
Description of the action / interactivity
Start Timeof the action
End Timeof the action
Audio narratio
nOn screen text
1. Image shows a typical maze of size 6x6 surrounded by walls
0 10
Problem Statement:
Find a path from start to finish by moving either horizontally or
vertically without going through the
walls.
Maze Routing Algorithm
15
1. Begin from the start node.2. Start node becomes live node.3. Now this live node will become the E-node.4. For start node apply the Precedence Rule no. 1.5. A. If empty node does not exist then Print ”No path found” and jump to step
10.B. Else make the new empty node as live node.
6. A. If this node is the finish node then we have successfully routed the maze. Jump to step 10.B. Else this node becomes our E-node.
7. Apply precedence rule to this E-node.8. A. If precedence no. 4 is selected then E-node becomes dead node. (This
node was already made live node previously).i. If the E-node is start node. then print “No path
found”. Jump to step 10.B. Else make the new empty node live node.
9. Jump to step 6.10.End.
Note: 1. A live node will remain alive unless it becomes dead. 2. There is only one E-node at any instant. 3. For Precedence Rule refer next slide.
Precedence rule
16
Case no. 1 :If the incoming direction is from the left, then precedence for selecting the new empty node is shown in the fig. (a).
Case no. 3 :If the incoming direction is from the right, then precedence for selecting the new empty node is shown in the fig. (c).
Case no. 2 :If the incoming direction is from the top, then precedence for selecting the new empty node is shown in the fig. (b).
Case no. 4 :If the incoming direction is from the bottom, then precedence for selecting the new empty node is shown in the fig. (d).
Figure (a)
Figure (b)
Figure (c)
Figure (d)
Supportive image for step 2 (fig. 0)
17
Start
Finish
Step 2 - Demo
18
Fig. No. Description of the action / interactivity
Start Timeof the action
End Timeof the action
Audio narrat
ionOn screen text
0. Display the maze shown in the previous slide and jump to fig 1.
0 sec 3 sec
Problem Statement:Find a path from start to finish by
moving either horizontally or vertically without going through the
walls.
1. The Start node becomes Live Node. 3 sec 4 sec The Start node becomes Live Node.
2. This node becomes E-node. This node becomes E-node.
3.Choose the next node using Precedence case no. 1. (Slide no. 16) and make it the Live Node.
Search for empty node scanning clockwise from the top. (Neglect diagonal nodes). This empty node becomes Live Node.
4. This node becomes E-node. The previous node loses its E-node status.
The recent Live Node becomes E-node. The previous node loses its E-node status.
5. The next Live Node is chosen using appropriate precedence rule.
The next Live Node is chosen by scanning clockwise from the direction that we entered.
6. This node becomes E-node. The previous node loses its E-node status.
This node becomes E-node. The previous node loses its E-node status.
Note: The nos. in the Fig. no. column represents the fig. no. mentioned in supportive images for step 2
Supportive image for step 2 (fig. 1)
19
Start
Finish
Supportive image for step 2 (fig. 2)
20
Start
Finish
Supportive image for step 2 (fig. 3)
21
Start
Finish
Supportive image for step 2 (fig. 4)
22
Start
Finish
Supportive image for step 2 (fig. 5)
23
Start
Finish
Supportive image for step 2 (fig. 6)
24
Start
Finish
Step 2 – Demo (contd.)
25
Fig. No. Description of the action / interactivity
Start Timeof the action
End Timeof the action
Audio
narration
On screen text
7.
Application of Precedence case no. 1 results in direction no. 4. So this node becomes Dead Node. The next node which was Live Node becomes E-node now.
For this node the outgoing direction is same as incoming direction so the node becomes Dead Node and the next node which was Live Node becomes E-Node
now.
8.The next Live Node is chosen using Precedence Rule case no. 3. The direction no. is 1.
Again using the same kind of clockwise scanning starting from the incoming direction the next Live Node is the node below the E-Node.
9. This node becomes E-node. The previous node loses its E-node status.
This node becomes E-node. The previous node loses its E-node status.
10.
The next Live Node is chosen using Precedence Rule case no. 2. The direction no. is 2. (This step is not shown in the example figures but the animator should show it by making the new live node green first *). This node becomes E-node.(only this step is shown in the figure.)
Scanning clockwise from right choose the next Live node which is below the current E-Node.
11-22 Refer to Maze Routing algorithm (slide no. 15) and match it with the fig. 11-22
<Enter appropriate text describing the next step in the algorithm>
* Note: This is continued in the next slide as well so please create appropriate intermediate figures for remaining steps.
Supportive image for step 2 (fig. 7)
26
Start
Finish
Supportive image for step 2 (fig. 8)
27
Start
Finish
Supportive image for step 2 (fig. 9)
28
Start
Finish
Supportive image for step 2 (fig. 10)
29
Start
Finish
Supportive image for step 2 (fig. 11)
30
Start
Finish
Supportive image for step 2 (fig. 12)
31
Start
Finish
Supportive image for step 2 (fig. 13)
32
Start
Finish
Supportive image for step 2 (fig. 14)
33
Start
Finish
Supportive image for step 2 (fig. 15)
34
Start
Finish
Supportive image for step 2 (fig. 16)
35
Start
Finish
Supportive image for step 2 (fig. 17)
36
Start
Finish
Supportive image for step 2 (fig. 18)
37
Start
Finish
Supportive image for step 2 (fig. 19)
38
Start
Finish
Supportive image for step 2 (fig. 20)
39
Start
Finish
Supportive image for step 2 (fig. 21)
40
Start
Finish
Supportive image for step 2 (fig. 22)
41
Start
Finish
Supportive image for step 2 (fig. 23)
42
Start
Finish
Question 1: Can a finish node become a Dead Node?
Answers:1. Yes 2. No 3. Sometimes
Correct answer: 2
Feedback/Justification to be displayed:• If user clicks correct answer then display: “Correct! As
soon as the Finish Node becomes Live Node, the algorithm terminates.”
• If user clicks incorrect answer then display “Have a look at the animation and Try again!”
43
Question 2:When Start Node becomes a Dead Node then
Answers:1. Path is found2. No path is found3. Start Node cannot become a Dead Node
Correct answer: 2
Feedback/Justification to be displayed:• If user clicks correct answer then display “Correct! As
soon as the Start Node becomes Dead Node, the algorithm terminates.”
• If user clicks incorrect answer then display “Have a look at the animation and Try again!”
44
Question 3: Consider the situation as shown in the figure,
The next E-node is..
Answers:a) 1b) 2c) 3d) 4
Correct answer: a
45
1
2 3
4
Feedback/Justification to be displayed:• If user clicks correct answer then display “Correct! Make sure you
can explain the reasoning!”• If user clicks incorrect answer then display “Scan Clockwise starting
from the incoming direction. The direction is from 2 as it the only Live Node other than the E-node.”
Question 4: If no path is found, then select the option which will always stand true..
Answers:a) All blocks are either Dead Nodes or walls.b) All blocks which were Live Nodes are Dead.c) There are no Dead Nodes.d) None of the above
Correct answer: b
46
Feedback/Justification to be displayed:• If user clicks correct answer then display “Correct! A node can
become a Dead Node only if it leaves E-node from the direction from which it entered.”
• If user clicks incorrect answer then display “Have a look at the animation and Try again!”
References
Website links:http://www.cise.ufl.edu/~sahni/dsaaj/JavaVersions/applications/ratmaze/maze.htm
Books: “Data Structures, Algotithms amd Analysis” by Sahni and Sartaj.
47