programming assignment, C/C++ Programming

Assignment Help:
Introduction. In this assignment you are required to simulate a maze traversal using so called recursive backtracking (the algorithm is given below).
The grid of #s and 0s in the following Figure is a two-dimensional array representation of a maze. The #s represent the walls of the maze, and the zeros represent locations in the possible paths through the maze. In the maze, you can move one step at a time in the following four directions: up, down, right, left, no “diagonal” moves are allowed. A move can be made only to a location in the array that contains a zero.
# # # # # # # # # # # #
# 0 0 0 # 0 0 0 0 0 0 #
0 0 # 0 # 0 # # # # 0 #
# # # 0 # 0 0 0 0 # 0 #
# 0 0 0 0 # # # 0 # 0 0
# # # # 0 # 0 # 0 # 0 #
# 0 0 # 0 # 0 # 0 # 0 #
# # 0 # 0 # 0 # 0 # 0 #
# 0 0 0 0 0 0 0 0 # 0 #
# # # # # # 0 # # # 0 #
# 0 0 0 0 0 0 # 0 0 0 #
# # # # # # # # # # # #
Write a recursive function called mazeTraversal, to walk through a maze like the one shown above.
The function mazeTraversal should attempt to locate the exit, it should also place the character ''x'' in each square in the path.
In mazeTraversal you are required to implement the following recursive algorithm:
ITECH 7603
Advanced Programming
School of Science, Information Technology and
Engineering
• From the current location in the maze, try to move one space in one of the four directions (down, right, up or left).
• If it is possible to move in at least one direction, call mazeTraversal recursively, passing the new location in the maze as the current location.
• If it is not possible to go in any direction, return to the previous location in the maze and try a new direction from that location
This recursive algorithm finds the exit (assuming there is an exit). If there is no exit, you will arrive at the starting location again.
Program the function to display the maze after each move so that the user can see how the maze is solved. The final output of the maze should display the path that solves the maze.
1. Class Maze. The Maze class should have:
A) Two private instance variables – int size, char **maze;
B) Constructor “Maze(char **c, int size)” – takes as an argument an n-by-n two-dimensional character array that contains only #s and 0s.
C) Public function void mazeTraversal(int a, int b)” – tries to “solve” the maze. Parameters a, b represent the entry point to the maze. Recursive algorithm for the mazeTraversal is described in the previous section.
D) friend ostream &operator<<(ostream &stream, Maze &m) – to print maze m in a tabular format.
E) Private function void mazeGenerator()” – randomly creates an n-by-n (3010==n) Maze object which has an entry point on the left side. The algorithm for mazeGenerator should be as follows:
• You start with 2-dimensional n-by-n array maze containing only #s, and then you “dig” your way through it until reaching a border, marking the visited cells with 0s.
• The entry point is maze[n/2][0]
• First move is to the right, after that you chose randomly any of four possible directions to move.
• The function stops when it reaches a border.
ITECH 7603
Advanced Programming
School of Science, Information Technology and
Engineering
F) Default constructor Maze() – calls the mazeGenerator.
2. main() function.
In the main function you should create three Maze objects:
• One on the figure in the section 0.
• A 12-by-12 maze that has an entry point but does not have an exit. You should design it yourself.
• A randomly generated maze object
Then the mazeTraversal function should be called on each of the created objects.

Related Discussions:- programming assignment

Explain formatted input output with file pointer, Explain Formatted Input O...

Explain Formatted Input Output with File Pointer? Likewise there are equivalents to the functions scanf and printf which write or read data to files. These are called fscanf a

Hep, I need help with a c# program. Do yall help with c sharp

I need help with a c# program. Do yall help with c sharp

Functions, Define  F u n c t i o n?  T h e r e a r e t...

Define  F u n c t i o n?  T h e r e a r e t w o t y p e s o f f u n ct i o n b u i l t - i n f un ct i o n s a n d u

Need discrete math tutor, Project Description: I will need a tutor that ...

Project Description: I will need a tutor that would help me out in Data Structure and learning Algorithm more at the mathematical/algorithmic level. The book is written by "by T

What does it mean to declare a member function as a virtual, What does it m...

What does it mean to declare a 1.      member function as a virtual A: (a) C++ virtual function is member function of any class, whose functionality may be over- ridden in

Minimization and karnaugh maps, There are formal ways of reducing Boolean e...

There are formal ways of reducing Boolean expressions in order to minimize the logic circuit. The two elementary ways of minimization are using Boolean expressions/De Morgan Theore

C program to string compression, C program to string compression: Writ...

C program to string compression: Write a program to define a sting and all operations on string. void main()                                 {

Float number, We can combine more than one variable on the same line i.e. ...

We can combine more than one variable on the same line i.e.   float number1,number2,number3; etc Sometimes we want to mix the variable types used on the same line, this could

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd