Question: A map is represented as a matrix of integer values. The starting cell of the map is always at the top-left corner (element 10.01). while
A map is represented as a matrix of integer values. The starting cell of the map is always at the top-left corner (element 10.01). while the ending cell is always at the bottom-right corner (element fr-1, C-1), where r and care the numbers of rows and cotumns of the matrix, respectively). It is possible to walk die., visit) the map by moving from one cell to any adjacent element (8 at most). but each cell has to be visited only once. Write the recursive the crunction matVisit that is able to find a path from the starting point to the ending point whose sum of the content of the visited cellis maximum. The function receives 4 parameters, the matrix mat, ils number of rows r. ils number of rows e, and a flagt void malVisit (int "mat, int , int c. int f): If there are more paths with the same (maximum) sum, the function has to display the shortest path if t=0 and the longest one it t=1. The desired path has to be displayed with a format similar to the one reported in the example. The following figure illustrates a matrix mat, with r=2 and C=2. (left-hand side) and the corresponding solution (right-hand side) 12 - 014 The indicated path should be reported with a format similar to the following one [0,0]1 - 10.12 - [1,019 - 12.131 - [1,2]7 - [2.2]4 - sum - 24 Specify (in C language) which is the logic followed by the function. A map is represented as a matrix of integer values. The starting cell of the map is always at the top-left corner (element 10.01). while the ending cell is always at the bottom-right corner (element fr-1, C-1), where r and care the numbers of rows and cotumns of the matrix, respectively). It is possible to walk die., visit) the map by moving from one cell to any adjacent element (8 at most). but each cell has to be visited only once. Write the recursive the crunction matVisit that is able to find a path from the starting point to the ending point whose sum of the content of the visited cellis maximum. The function receives 4 parameters, the matrix mat, ils number of rows r. ils number of rows e, and a flagt void malVisit (int "mat, int , int c. int f): If there are more paths with the same (maximum) sum, the function has to display the shortest path if t=0 and the longest one it t=1. The desired path has to be displayed with a format similar to the one reported in the example. The following figure illustrates a matrix mat, with r=2 and C=2. (left-hand side) and the corresponding solution (right-hand side) 12 - 014 The indicated path should be reported with a format similar to the following one [0,0]1 - 10.12 - [1,019 - 12.131 - [1,2]7 - [2.2]4 - sum - 24 Specify (in C language) which is the logic followed by the function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
