Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will create a program reads in a grid of elevation data. Your program will compute some overall statistics about the data.

In this assignment, you will create a program reads in a grid of elevation data. Your program will compute some overall statistics about the data. It will find a path crossing the grid from west to east while trying to minimize the path's elevation change. There are many contexts in which you want to know the most efficient way to travel over land. When traveling through mountains (let's say you're walking) perhaps you want to take the route that requires the least total change in elevation with each step you take call it the path of least resistance. Given some topographic data it should be possible to calculate a "greedy lowest-elevation-change walk" from one side of a map to the other.

The basic stats needed are the number of data points read in, average elevation displayed to two decimal places, minimum elevation in the data, and the maximum elevation in the data.

Also include a verbose mode. In verbose mode, the program also prints out the path taken starting at each row. The verbose mode is turned on by providing a non-zero integer as the first command line argument to the program. Note this means if 0 is given as a command line argument the program should not print verbose output. Here is an example with verbose output turned on:

./East 1 < small.txt Data points: 30 Avg elevation: 2878.40 Min elevation: 2742 Max elevation: 3011 (0,0) 3011 D, (1,1) 2937 D, (2,2) 2913 D, (3,3) 2910 D, (4,4) 2962 F, (5,4) 2798, cost 317 (0,1) 2972 D, (1,2) 2959 D, (2,3) 2986 D, (3,4) 2997 F, (4,4) 2962 F, (5,4) 2798, cost 250 (0,2) 2937 U, (1,1) 2937 D, (2,2) 2913 D, (3,3) 2910 D, (4,4) 2962 F, (5,4) 2798, cost 243 (0,3) 2999 U, (1,2) 2959 D, (2,3) 2986 D, (3,4) 2997 F, (4,4) 2962 F, (5,4) 2798, cost 277 (0,4) 2909 U, (1,3) 2888 D, (2,4) 2893 U, (3,3) 2910 D, (4,4) 2962 F, (5,4) 2798, cost 259 Best: row 2, cost 243

This is a copy of the example text file used above.

6 5 3011 2900 2852 2808 2791 2818 2972 2937 2886 2860 2830 2748 2937 2959 2913 2864 2791 2742 2999 2888 2986 2910 2821 2754 2909 2816 2893 2997 2962 2798

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

6. What is process reengineering? Why is it relevant to training?

Answered: 1 week ago