Question: Using dynamic programming min cost path algorithm . Design an algorithm to solve the following problem: Suppose you are given an nxn grid of non-negative

Using dynamic programming min cost path algorithm .
Design an algorithm to solve the following problem: Suppose you are given an nxn grid of non-negative integers. This grid represents an elevation map for a region, with each integer denoting the elevation of region within that particular grid square. Your job is to design an algorithm that computes a relatively level path through the mountains from the leftmost column of the map to the rightmost colum (you may start and end at any position on the left/right respectively). Movement along the path allows for left/rightm, up/down movement, as well as diagonal movement. The cost of each step in the path is the absolute value of the eleveation change between the two positions moved between. For example, here is an input grid: 
 5 8 3 3 
3 2 4 9 
3 3 2 8 
2 2 7 1 
 Below, marked by o's, is a proposed optimal path that achieves cost 1 (because |2-2| + |2-2| + |2-2| + |2-3| + |3-3| = 1 ). 
 xxoo
 xoxx 
xxox 
ooxx

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!