Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 1 : Maze exploration using recursive function A Maze is given as N * N binary matrix of blocks where source block is the
Part : Maze exploration using recursive function
A Maze is given as NN binary matrix of blocks where source block is the upper left most block ie maze and destination block is lower rightmost block ie mazeN N A rat starts from the source and has to reach the destination. The rat can move in four directions ie left,
right, up or down
In the maze matrix, means the block is a dead end and nonzero means the block can be used in the path from source to destination, where nonzero value indicates the number of maximum jumps the rat can make from the cell mazeij Also, a weight is applied to each cell in the path that is not deadblock, source or destination. The cell weight is set to be 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. Also, at any intermediate point along the longest path, make sure that you explore all the neighbours at that point to reach destination.
Objective:
Find the longest path from source to destination considering the cell weights in the path with multiple movement jumps.
Algorithm:
Create a solution matrix, initially filled with s
Create a recursive function, which takes initial matrix, output matrix and position of rat i j
if the position is out of the matrix or the position is not valid then return.
Mark the position outputij as and check if the current position is destination or not. If destination is reached print the output matrix and return.
Find all the neighbouring cells that are still open at the current position and recursively call for four movement directions.
Unmark position i j ie outputij
Constraints:
Jump value mazeij is in range
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 D array and print out the maze solution correspondingly if there is a path existing. The output matrix contains and where mazeij represents the cell is taken into the path and mazeij represents if any path exists.
Part : Huffman decoding using recursive functions
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.
We start from root and do following until a leaf is found.
If current bit is we move to left node of the tree.
If the bit is we move to right node of the tree.
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
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started