subject

You decide to take a break from computer science, and instead go into environmental engineering. Luckily, your computer science skills will come in handy! Your first job is to deal with modeling the water run-off – or drainage – in a basin area. Given a representation of the area to model, your task is to determine how far the water will flow.
The land will be represented by topographical map, which is a two-dimensional square grid of elevations.
Each grid will have n rows and n columns. Each grid location – or grid cell – will have a non-negative
integer height elevation.
The input files will be formatted such that the first line contains the dimensionality of the grid, and the remaining lines will represent the values in the grid. Columns are separated by a space, rows separated by newlines.
Your task is to figure out the longest sequence of grid locations that water can flow between. Water will flow from a higher elevation to a lower elevation. For the purposes of this problem, water will never flow from a given elevation to the same elevation, nor will it flow uphill. Furthermore, water can only flow from one grid cell to an adjacent cell (adjacent cells are above, below, left, and right; not diagonal!).
As an example, consider the following 5x5 grid (this is sample. txt in this exercise’s zip file). Note that the input in this example is justified to help illustrate the grid; there will only be one space between heights in the actual input. Recall that the first line indicates the grid’s size.
5
66 78 41 3 77
4 90 41 8 68
12 11 29 24 53
0 51 58 9 28
97 99 96 58 92
There are many such valid drainage paths in this grid. One starts in the second cell of the second row, and
flows from 90-78-41-3. Note that 90-41-41-3 is not a valid drainage flow, as water is not always flowing
downhill (41-41 is not downhill). The longest drainage path in this example is of length 7, and flows from
the 99 in the bottom row to the 3 in the top row; the full path is 99-96-58-29-24-8-3.
You may solve this problem using top-down Dynamic Programming or using bottom-up Dynamic
Programming. We think that top-down will be much easier here, but you do you. Certainly a brute-force
solution’s running time will be too long. Likely the best way to check that your algorithm is properly
Dynamic Programming is to comment out the portion where you look up solutions to subproblems. If
the algorithm gets substantially slower, then you are (or rather were) using DP!
You should be able to obtain an algorithm that runs in n 2 time, but your algorithm definitely should not
run in ω(n3) time. You do not need to justify the running time of your algorithm.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:10
Problem 1 - hashing we would like to use initials to locate an individual. for instance, mel should locate the person mark e. lehr. note: this is all upper case. generate a hash function for the above using the numbers on your telephone. you know, each letter has a number associated with it, so examine your telephone keypad. generate 512 random 3 letter initials and take statistics on a linked list array size 512 to hold this information report how many have no elements, 1 element, 2 elements, does this agree with the hashing statistics distribution?
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Select the correct answer from each drop-down menu. which types of computer networks are bigger as well as smaller than a man? a man is a network of computers that covers an area bigger than a , but smaller than a .
Answers: 1
question
Computers and Technology, 23.06.2019 22:50
An environmental protection agency study of 12 automobiles revealed a correlation of 0.47 between engine size and emissions. at 0.01 significance level, can we conclude that there is a positive association between the variables? what is the p value? interpret.
Answers: 2
question
Computers and Technology, 24.06.2019 11:00
These statements describe lists in presentation programs: a. bullets can be turned off and on. b. bullets cannot be turned off. c. bullet styles, colors, and sizes can be changed. d. lists don't have to use bullets or numbers. e. numbering styles, colors, and sizes can be changed. f. numbers can be turned off and on. g. numbers cannot be turned off. select all that apply
Answers: 2
You know the right answer?
You decide to take a break from computer science, and instead go into environmental engineering. L...
Questions
question
Mathematics, 16.10.2020 15:01
question
Social Studies, 16.10.2020 15:01
question
Mathematics, 16.10.2020 15:01
question
Mathematics, 16.10.2020 15:01
question
Mathematics, 16.10.2020 15:01
question
Mathematics, 16.10.2020 15:01
Questions on the website: 13722363