Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem Description Figure 1 illustrates a grid of 3 - by - 3 where each cell ( square ) contains number of carrots. For example,
Problem Description
Figure illustrates a grid of by where each cell square contains number of carrots. For example, in the Start cell there is one carrot and in the End cell there are carrots. The rabbit shown below aims to start a journey from Start cell toward End cell and to collect the maximum number of carrots. The rabbit can only move in Right direction or Top direction as shown by the arrows below.
Thus, the ultimate objective of this problem is to find the best path in the grid that results in the collection of maximum number of carrots.
Figure Graphical representation of the problem of finding the best path results in the maximum number of carrots.
Hints for Solving the Problem
There are different approaches for solving this problem. One approach is to consider the following rules for finding the best path and finally maximum number of carrots:
In the Start cell, the maximum number of carrots is the number of carrots indicated.
The maximum number of carrots for other cells is equal to summation of number carrots on that cell with maximum number of carrots on the adjacent cells.
For example, for the following by grid, we have:
Right
Thus, the maximum number of collected carrot is and the best path is:
Grid Grid Grid
MATLAB Coding
For the problem given in Section write a MATLAB program that returns the best path taken by the rabbit from starting point to the end point and the maximum number of carrots collected by the rabbit.
Your MATLAB program should at least contain one function file and one script calling the function file to produce the result on the Command Window. The script should receive the information of the grid and then call the function file to solve it The output on the Command window should be like this:
The best path is: Grid Grid dots, Grid
The maximum number of carrots collected is:
Grid
Righ
Thus, the maximum number of collected carrot is and the best path is:
Grid Grid Grid
MATLAB Coding
For the problem given in Section write a MATLAB program that returns the best path taken by the rabbit from starting point to the end point and the maximum number of carrots collected by the rabbit.
Your MATLAB program should at least contain one function file and one script calling the function file to produce the result on the Command Window. The script should receive the information of the grid and then call the function file to solve it The output on the Command window should be like this:
The best path is: Grid Griddots,Grid
The maximum number of carrots collected is:
Important Note: Your MATLAB program should be comprehensive and can be applied on any by grid. It means that if you feed a new grid with different number of carrots in each cell comparing to the above grid to your MATLAB program, it should be able to solve it You should show this verification as well.
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