want C Programming paper

want C Programming paper

page 1 of 4

Math 230 Project 1: Mountain Hike Path In this lab you will read a set of topographic (land elevation) data from a 2D array and write a function to compute the path(s) through the mountains. Background: 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. A Greedy Walk A “greedy” algorithm is one in which, in the face of too many possible choices, you make a choice that seems best at that moment. For the maps we are dealing with there are many possible paths you could take starting from the “western” side of the map and taking one step forward until you reach the “eastern” side. Since our map is in a 2D grid, we can envision a “walk” as starting in some in some cell at the left-most edge of the map (column 0) and proceeding forward by taking a “step” into one of the 3 adjacent cells in the next column over (column 1). Our “greedy walk” will assume that you will choose the cell whose elevation is closest to the elevation of the cell you’re standing in. (NOTE: this might mean walking uphill or downhill). The overall sum of the changes will be calculated by taking the absolute value of the sum of the changes. Since your code does not know which of the 5 rows will yield the best result, you will calculate 5 sums and then select the smallest value as the best answer. Your program should return the index of each row, and the associated best-sum for that row.

Shows a portion of the data. Greedy path shown in green.

page 2 of 4

The diagrams below show a few scenarios for choosing where to take the next step. In the case of a tie with the forward position, you should always choose to go straight forward. In the case of a tie between the two non-forward locations, you should flip a coin to choose where to go. That means you will need to use rand() to make a decision for ties.

Case 1: smallest change is 5, go fwd- down

Case 2: smallest change is 3, go fwd

Case 3: smallest change is a tie (3), fwd is an option, so go fwd

Case 4: smallest change is a tie (4), choose randomly between fwd- up or fwd-down

page 3 of 4

Use pathFind.c to start your project. The main() function should not be modified, but the function calcSums(int topog[ROWS][COLS], int sumList[ROWS] )

will be modified. It should be coded to receive a 2d array as input, calculate the elevation sums, and insert the sums into the array sumList[ ]. Main() will print out the values inserted into sumList[ ].

The objective is to use each row of the first column of the 2d array as a starting point to come up with a sum of absolute value of differences. For each row, a sum will be calculated, therefore, 5 sums must be calculated. Each sum will be placed into the array, sumList[ ].

page 4 of 4

RUBRIC: stu: Proj 1 Lowest Total Sum of Elev Changes ======================================== Your function prototype(s): void calcSums(int topog[ROWS][COLS], int sumList[ROWS] ); Input data: int topography[ROWS][COLS] = { { 3011, 2800, 2852, 2808, 2791, 2818 }, //74+24+3+52+164=317 { 2972, 2937, 2886, 2860, 2830, 2748 }, //13+46+3+52+164=278 { 2937, 2959, 2913, 2864, 2791, 2742 }, //0+24+3+52+164=243 { 2999, 2888, 2986, 2910, 2821, 2754 }, //40+27+11+35+164=277 { 2909, 3816, 2893, 2997, 2962, 2798 } //21+5+17+52+164=259 }; —————– Rubric: 1. read and use 2d array data 2. appropriate and useful data types 3. write correct output to the terminal 4. modularity (selection of methods, use of arrays, switch/case, etc.) 5. comments, white space,indentation, general structure Coding conventions: http://www.oracle.com/technetwork/java/codeconv-138413.html —————– Programs that don’t compile: -5 Programs that don’t calculate sum correctly: -4 —————– points for above: —————– 1. correctly read input: /1 2. data types: /1 3. correctness: /4 4. modularity: /1 5. structure/org: /1 total: /8 Expected Outputs: ==================== 0, 317 1, 250 2, 243 3, 277 4, 259 Instructor Comments:

Program console output appended below:

The post want C Programming paper appeared first on Lion Essays.


“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”

want C Programming paper was first posted on February 14, 2019 at 12:38 am.
©2019 "Lion Essays". Use of this feed is for personal non-commercial use only. If you are not reading this article in your feed reader, then the site is guilty of copyright infringement. Please contact me at support@Lion Essays.com

"Get 15% discount on your first 3 orders with us"
Use the following coupon

Order Now