Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Grid ( 2 , 2 ) Righ Thus, the maximum number of collected carrot is 9 and the best path is: Grid ( 1 ,

Grid (2,2)
Righ
Thus, the maximum number of collected carrot is 9 and the best path is:
Grid (1,1), Grid (1,2), Grid (2,2)
3. MATLAB Coding
For the problem given in Section 1, 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 fProblem Description
jure 1 illustrates a grid of 3-by-3 where each cell (square) contains number of rrots. For example, in the Start cell there is one carrot and in the End cell there e 5 carrots. The rabbit shown below aims to start a journey from Start cell toward d cell and to collect the maximum number of carrots. The rabbit can only move Right direction or Top direction as shown by the arrows below.
hus, the ultimate objective of this problem is to find the best path in the grid that sults in the collection of maximum number of carrots.
Right
Figure 1. 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:
Grid (2,2)
Righ
Thus, the maximum number of collected carrot is 9 and the best path is:
Grid (1,1), Grid (1,2), Grid (2,2)
3. MATLAB Coding
For the problem given in Section 1, 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 (1,1),Grid(,),dots,Grid(3,3)
The maximum number of carrots collected is:
Important Note: Your MATLAB program should be comprehensive and can be applied on any N-by-M 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.
2
Problem Description
Figure 1 illustrates a grid of 3-by-3 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 5 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 1. Graphical representation of the problem of finding the best path results in the maximum number of carrots.
2. 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 2-by-2 grid, we have:
Right
Thus, the maximum number of collected carrot is 9 and the best path is:
Grid (1,1), Grid (1,2), Grid (2,2)
3. MATLAB Coding
For the problem given in Section 1, 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 (1,1), Grid (,),dots, Grid(3,3)
The maximum number of carrots collected is:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

How is weighted-average unit contribution margin calculated?

Answered: 1 week ago

Question

What is an organizational feasibility analysis?

Answered: 1 week ago