![chelseal19847](/avatars/46918.jpg)
chelseal19847
05.05.2021 •
Computers and Technology
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.
Solved
Show answers
More tips
- F Family and Home How to Teach Your Child to Read?...
- C Computers and Internet How to Download Videos from YouTube? Simple Steps to Download Any Content...
- S Style and Beauty Tricks and Tips: How to Get Rid of Freckles...
- H Health and Medicine How to perform artificial respiration?...
- C Computers and Internet How to Get Rid of Windows Genuine Check?...
- F Food and Cooking The Disease That Haunted Abraham Lincoln...
- S Style and Beauty How to Make Your Lips Fuller? Ideas and Tips for Beautiful Lips...
- S Style and Beauty How are artificial nails removed?...
- F Family and Home How to Sew Curtain Tapes: Best Tips from Professionals...
- H Horoscopes, Magic, Divination How to Cast a Love Spell on a Guy? Guide for Guys...
Answers on questions: Computers and Technology
- M Mathematics What is the slope of the line that contains these points? x=9,13,17,21 and y =-24,-21,-18,-15...
- P Physics Suppose your are looking at a yellow fish in a fish tank. the tank is next to a window. describe the path light takes in order for you to see the fish, starting at the sun...
- M Mathematics The equation of line G is y = 2x + 3. Line H passes through the point (0, 4) If the two lines intersect at exactly one point, what could be a second point on line H?...
Ответ:
Through after school programs
Explanation:
Under represented and under resourced students can be better engaged in STEM programs through the establishment of after school state of the arts learning centres that can augment for the vacuum in the regular school system.
In such programs, the use of technological platforms with an integrated electronic learning system is necessary, because it avails the students the opportunity to brace up with the evolving impact of information technology to learning and personal developments.
Secondly, the use of immediate resources within the reach of these under privileged and under resourced students is a necessity. for example, a student in a rural community could start become more engage in engineering designs, building technology, instrumentation and architecture through the use of disposed cartons used to construct buildings, cars etc.