Question: MAZE.CPP #include maze.h #include namespace data_structures_assignment_5 { maze_node::maze_node(maze_node* left, maze_node* right, bool init_finish) { left_ptr = left; right_ptr = right; finish = init_finish; } maze_node::~maze_node()
MAZE.CPP
#include "maze.h" #includenamespace data_structures_assignment_5 { maze_node::maze_node(maze_node* left, maze_node* right, bool init_finish) { left_ptr = left; right_ptr = right; finish = init_finish; } maze_node::~maze_node() { delete right_ptr; delete left_ptr; } maze::maze(int maze_number) { assert(maze_number == 0 || maze_number == 1); if(maze_number == 0) { build_maze0(); } else if(maze_number == 1) { build_maze1(); } } maze_node* maze::get_start() { return start_node_ptr; } void maze::build_maze0() { maze_node* node_ptr0; maze_node* node_ptr1; maze_node* node_ptr2; maze_node* node_ptr3; maze_node* node_ptr4; maze_node* node_ptr5; maze_node* node_ptr6; maze_node* node_ptr7; maze_node* node_ptr8; node_ptr8 = new maze_node(nullptr, nullptr, true); node_ptr7 = new maze_node(nullptr, nullptr); node_ptr6 = new maze_node(nullptr, node_ptr7); node_ptr5 = new maze_node(nullptr, nullptr); node_ptr4 = new maze_node(node_ptr8, nullptr); node_ptr3 = new maze_node(nullptr, nullptr); node_ptr2 = new maze_node(node_ptr6, node_ptr5); node_ptr1 = new maze_node(node_ptr4, node_ptr3); node_ptr0 = new maze_node(node_ptr2, node_ptr1); start_node_ptr = node_ptr0; } void maze::build_maze1() { maze_node* node_ptr0; maze_node* node_ptr1; maze_node* node_ptr2; maze_node* node_ptr3; maze_node* node_ptr4; maze_node* node_ptr5; maze_node* node_ptr6; node_ptr6 = new maze_node(nullptr, nullptr, true); node_ptr5 = new maze_node(node_ptr6, nullptr); node_ptr4 = new maze_node(nullptr, nullptr); node_ptr3 = new maze_node(nullptr, nullptr); node_ptr2 = new maze_node(node_ptr4, node_ptr5); node_ptr1 = new maze_node(nullptr, node_ptr3); node_ptr0 = new maze_node(node_ptr2, node_ptr1); start_node_ptr = node_ptr0; } maze::~maze() { delete start_node_ptr; } }
----------------------------------------------------------------------------------------------------------------
QUESTION:

bool print_path_through_maze(const maze_node* maze_position) // Postcondition: Prints the path through the maze, with 0s representing right // turns and 1s representing left turns. // You may print the path in reverse order (this will be easier). // Hint: Use the return boolean to signify that the current path is the correct path. { return true; }The maze solving function Imagine a maze which at every intersection branches either to the left, to the right, or both at each new intersection, as shown in Figure 1. Starting from the blue node, you want to know the path to the green node, taking either the right or left paths (moving upward from the bottom) Write a function which will print this path printing Os for left turns and 1s for right turns. You may print the path in reverse order (this will be easier) Use the maze class provided by maze.h to test your maze solving code. The constructor for maze takes an integer for which maze to build. Maze 0 and 1 are provided. The get start will give you the starting node of the maze From each maze_node you can check if the left) or right ) function of that maze_node leads to another maze node or to the nullptr. The nullptr signifies a deadend in the maze. The is finish) function of a maze node will return true if it is the finish node and false otherwise. You do not need to change the maze code in any way, unless you want to add additional mazes to test. Your code will be tested a different maze than just these two during grading. You can assume there will always be a finish node with an available path to it. You can also assume that each node has only one node that leads to it The maze solving function Imagine a maze which at every intersection branches either to the left, to the right, or both at each new intersection, as shown in Figure 1. Starting from the blue node, you want to know the path to the green node, taking either the right or left paths (moving upward from the bottom) Write a function which will print this path printing Os for left turns and 1s for right turns. You may print the path in reverse order (this will be easier) Use the maze class provided by maze.h to test your maze solving code. The constructor for maze takes an integer for which maze to build. Maze 0 and 1 are provided. The get start will give you the starting node of the maze From each maze_node you can check if the left) or right ) function of that maze_node leads to another maze node or to the nullptr. The nullptr signifies a deadend in the maze. The is finish) function of a maze node will return true if it is the finish node and false otherwise. You do not need to change the maze code in any way, unless you want to add additional mazes to test. Your code will be tested a different maze than just these two during grading. You can assume there will always be a finish node with an available path to it. You can also assume that each node has only one node that leads to it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
