Develop a solution by using recursive functions

Assignment Help Other Subject
Reference no: EM133155382

ICT208 Algorithms and Data Structures

Case study 1

In this assessment, students will analyze a case and develop a solution by using recursive functions and finally write code.

Part A: Maze exploration using recursive function

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[N 1][N-1]. A rat starts from the 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. Your main program should have an option that allows the program to find a solution using either 2 way movement or 4 way movement.

Part B: Huffman decoding using recursive functions

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.

 

Reference no: EM133155382

Questions Cloud

Determine the taxpayer current-year economic income : Determine the taxpayer's current-year (1) economic income and (2) gross income for tax purposes from the following events
How could you monitor that plan and monitor the risk : Security has been identified as a risk at your warehouse. A plan has been put in place to reduce the risk. How could you monitor that plan and monitor the risk?
Describe the national security strategy : Describe the National Security Strategy. Explain how it effects the military. Provide example.
Determine last year margin of safety in sales dollars : Annual fixed costs are $225,000, and variable costs are 45 percent of sales revenue. Determine last year margin of safety in sales dollars
Develop a solution by using recursive functions : Analyze a case and develop a solution by using recursive functions and finally write code - Maze exploration using recursive function
Prisoner right-prison and prisoners is very unique situation : The administration of a prison and prisoners is a very unique situation that most individuals will never experience.
Subject to a charge of criminal conspiracy : The 1987 "Anti-Kickback Statute" (MMPPA) prohibits giving of or receiving compensation in exchange for referrals for Medicare or Medicaid services or goods.
Look for unique and creative ideas : Select 5 team building activities and explain why you chose this item and what type of event you would use it at
What corrections should be made to the trial balance : Alpha received cash of $300 in advance from a customer that has not yet been earned, What corrections should be made to the trial balance

Reviews

Write a Review

Other Subject Questions & Answers

  Reflect on your professional growth

Reflect and discuss how addressing the service/program gaps within your chosen municipality will benefit the community residing in the area.

  Construct method of conceptualizing and implementing lesson

Construct a method of conceptualizing and implementing the lesson you have created in terms of diverse population groups with your students.

  What problems or opportunities would each of the study

Identify three possible research topics related to coaching and professional development with virtual teams.

  Eilleen gray house-deas about public and private spaces

And make a diagrams and in the diagrams showing her ideas about public and private spaces.

  Change the nature of the american government

Did the World War I effort significantly change the nature of the American government or American society?

  How does the rhythmic vitality of bartok music compare

How does the rhythmic vitality of Bartók’s music compare with that of Stravinsky’s music?

  Has henrietta any claim against the firm for mental distress

Henrietta engaged a firm of solicitors to obtain an injunction to prevent a former male friend from visiting her and making a nuisance of himself. Has Henrietta any claim against the firm for ‘mental distress and upset'

  How does personality apply to counseling theories

What is the philosophy of the counseling profession? How has this changed over time? How does personality apply to counseling theories?

  Discuss the primary function of the organization

Please review the website above and discuss the primary function of the organization and identify professional standards of practice discussed on the website.

  Discuss the role of genetics on development

Discuss and give specific examples of the role of genetics on development within a family unit. Consider the impact of non-shared environmental effects

  Discuss each given studys strengths and weaknesses

Discuss each study's strengths and weaknesses. In light of what you've found in your analyses of these studies, discuss future research needs.

  How the article was easy or difficult to understand and why

Explain how the article was easy or difficult to understand and why? Describe what you believe the author could have done better in your opinion?

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