Beruflich Dokumente
Kultur Dokumente
File
STRUCTURE
Assignment ONE
MAZE
BLAGWA
MAZE
Identification
Notes :
1
Index
1. Problem Statement 3
• Stack 3
• Queue 3
• Solve Maze 4
• Bonus 5
2. Overall System 6
• Description 6
• View 8
2
Problem
Statement
3
Problem
Statement
4
Problem
Statement
5
Ovarall system
6
Ovarall system
• CommaToSpaceAdjustor.jar To
adjust the input.
• MazeCheck.jar To check validity of
the maze
• MazeView.jar To view the maze
12 I/O Files
• StackTestCasesInput.in
• StackTestCasesOutput.out
• QueueTestCasesInput.in
• QueueTestCasesOutput.out
• MazeGeneration.in
• Maze.in
• MazeCheck.out
• MazeView.out
• StackMazeSolverOutput.out
• StackMazeSolverCheckResult.out
• QueueMazeSolverOutput.out
• QueueMazeSolverCheckResult.out
7
Ovarall system
8
Under
Microscope
• Stack
Structure Node
parameter : element => Data to store
Next Pointer to a structure => Next in the line
Class Stack
Description : Stack is a linked LiFo Data
Structure implemented the Dummy header
Node linked list
Parameter : size integer => number of
elements in the stack
head Pointer to a structure => The first
Dummy Node in the stack
Behavior : Pop => to get the last inserted
element in the stack and remove it from the
stack
push => to insert in the stack
top => to get the last inserted element in the
stack without removing it
getSize => to get the number of element that
the stack store till now
inEmpty => return true if the size = zero
other wise return false
9
Under
Microscope
• Stack
Main
=> for testing the stack
step 1 : read from file "StackTestCasesInput"
step 2 : read the operation
step 3 : write the result in
"StackTestCasesOutput.out"
10
Under
Microscope
• Queue
Structure Node
parameter : element => Data to store
Next Pointer to a structure => Next in the line
Prev Pointer to a structure => Prev in the line
Class Queue
Description : Queue is a linked fiFo Data
Structure implemented the Dummy header
and footer Node linked list
Parameter : size integer => number of
elements in the queue
head Pointer to a structure => The first
Dummy Node in the queue
head tail to a structure => The last Dummy
Node in the queue
Behavior : dequeue => to get the first
inserted element in the queue and remove it
from the queue
enqueue => to insert in the queue
first => to get the first inserted element in
the queue without removing it
getSize => to get the number of element that
the queue store till now
inEmpty => return true if the size = zero
other wise return false
11
Under
Microscope
• Queue
Main
=> for testing the stack
step 1 : read from file
"QueueTestCasesInput.in"
step 2 : read the operation
step 3 : write the result in
"QueueTestCasesOutput.out"
12
Under
Microscope
• //Queue
• Order = n^2
• Gets always the shortest path
• Constant (time of execution depend only on
n)
• //Stack
• Order = n^2
• Not a condition to get the shortest path
• Execution time vary (from 2n to n^2)
14
Under
Microscope
• Maze Generation
Get x, y
Array maze[x*y]
Fill maze = wall
For(I 0:x*y)
{
maze[i]=free
if (i in the first row)
maze[i+1]=free
else if(I on the last column)
maze[i-y]=free
else
random
if (random)
maze[i+1]=free
else
maze[i-y]=free
}
maze[x*y-1]=free
15
Under
Microscope
• Maze Generation(1)
Get x, y
Array maze[x*y]
Fill maze = wall
For(I 0:x*y)
{
if(I in an odd row)continue
maze[i]=free
if (i in the first row)
maze[i+1]=free
else if(I on the last column)
maze[i-y]=free
else
random
if (random)
maze[i+1]=free
else
maze[i-y]=free
}
maze[x*y-1]=free
16
Under
Microscope
Complementary
• Path Validator
Check if
1) The path starts at the start point
2) The path doesn’t jump
3) The path doesn’t hit a wall
4) The path ends at the end point
• Maze Validator (fluid fill)
Color the start with special color
Color the neighbours with the same
color
return start color = end color
• Maze View
Loop on the maze input
If wall print X
Else print *
17