Part A: Maze exploration using recursive function (30%) A Maze is given as N*N binary matrix of blocks where source block is the upper left most block i.e., maze[0][0] and destination block is lower rightmost block i.e., maze[N1][N-1]. A rat starts from source and has to reach the destination. The rat can move in four directions: left, right, up or down. In the maze matrix, 0 means the block is a dead end and 1 means the block can be used in the path from source to destination. Backtracking is an algorithmic technique for solving problems recursively by trying to build a solution incrementally in maze exploration. Suggested Approach: Form a recursive function, which will follow a path and check if the path reaches the destination or not. If the path does not reach the destination then backtrack and try other paths. Algorithm: 1. Create a solution matrix, initially filled with 0’s. 2. Create a recursive function, which takes initial matrix, output matrix and position of rat (i, j). 3. if the position is out of the matrix or the position is not valid then return. 4. Mark the position output[i][j] as 1 and check if the current position is destination or not. If destination is reached print the output matrix and return. 5. Recursively call for position (i+1, j) and (i, j+1). 6. Unmark position (i, j), i.e output[i][j] = 0. Your task is to implement the given algorithm in C++ with recursive functions. You need to test the solution in a main function by creating a 2D array and print out the maze solution correspondingly if there is a path existing. There are a few existing websites for reference on maze exploration using recursion

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Part A: Maze exploration using recursive function (30%)
A Maze is given as N*N binary matrix of blocks where source block is the upper left
most block i.e., maze[0][0] and destination block is lower rightmost block i.e., maze[N1][N-1]. A rat starts from source and has to reach the destination. The rat can move in
four directions: left, right, up or down.
In the maze matrix, 0 means the block is a dead end and 1 means the block can be
used in the path from source to destination. Backtracking is an algorithmic technique
for solving problems recursively by trying to build a solution incrementally in maze
exploration.
Suggested Approach: Form a recursive function, which will follow a path
and check if the path reaches the destination or not. If the path does not
reach the destination then backtrack and try other paths.
Algorithm:
1. Create a solution matrix, initially filled with 0’s.
2. Create a recursive function, which takes initial matrix, output matrix
and position of rat (i, j).
3. if the position is out of the matrix or the position is not valid then
return.
4. Mark the position output[i][j] as 1 and check if the current position is
destination or not. If destination is reached print the output matrix
and return.
5. Recursively call for position (i+1, j) and (i, j+1).
6. Unmark position (i, j), i.e output[i][j] = 0.
Your task is to implement the given algorithm in C++ with recursive functions. You
need to test the solution in a main function by creating a 2D array and print out the
maze solution correspondingly if there is a path existing.
There are a few existing websites for reference on maze exploration using recursion
for you:
https://www.geeksforgeeks.org/rat-in-a-maze-backtracking-2/
https://learn.saylor.org/mod/book/view.php?id=33001&chapterid=12855
https://runestone.academy/ns/books/published//pythonds/Recursion/ExploringaMaze
.html
Part B: Huffman decoding using recursive functions (10%)
We have discussed Huffman encoding for data compression in lecture and tutorial,
now we can implement the Huffman decoding for data extraction to recover the
original data.
To decode the encoded data, we require the Huffman tree. We iterate through the
binary encoded data. To find character corresponding to current bits, we use
following simple steps.
1. We start from root and do following until a leaf is found.
2. If current bit is 0, we move to left node of the tree.
3. If the bit is 1, we move to right node of the tree.
4. If during traversal, we encounter a leaf node, we print character of that
particular leaf node and then again continue the iteration of the encoded
data starting from step 1.
Your task is to implement the Huffman decoding algorithm from the above steps in a
C++ program with Huffman decoding function and a main function to decode a
compressed string based on Huffman encoding and display the original string.
There are a few existing websites for reference on Huffman decoding algorithm for
you:
https://www.geeksforgeeks.org/huffman-decoding/
https://www.codespeedy.com/huffman-decoding-in-cpp/
https://www.programiz.com/dsa/huffman-coding

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY