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 03:10
Acomputer has a two-level cache. suppose that 60% of the memory references hit on the first level cache, 35% hit on the second level, and 5% miss. the access times are 5 nsec, 15 nsec, and 60 nsec, respectively, where the times for the level 2 cache and memory start counting at the moment it is known that they are needed (e.g., a level 2 cache access does not even start until the level 1 cache miss occurs). what is the average access time?
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
[java] create an application called registrar that has the following classes: a. a student class that minimally stores the following data fields for a student: - name - student id number - number of credits - total grade points earned and this class should also be provides the following methods: - a constructor that initializes the name and id fields - a method that returns the student name field - a method that returns the student id field - methods to set and retrieve the total number of credits - methods to set and retrieve the total number of grade points earned. - a method that returns the gpa (grade points divided by credits) b. an instructor class that minimally stores the following data fields for an instructor: - name - faculty id number - department the following methods should be provided: - a constructor that initializes the name and id fields - methods to set and retrieve the instructor’s department. c. a course class that minimally stores the following data for a course: - name of the course- course registration code- maximum number of 35 students- instructor- number of students- students registered in the course (an array)the following methods should also be provided: - a constructor that initializes the name, registration code, and maximum number of students- methods to set and retrieve the instructor- a method to search for a student in the course; the search should be based on an id number.- a method to add a student to the course. if the course is hill, then an exception with an appropriate message should be raised (try creating your own exception class for this). also, be sure that the student is not already registered in the course. the list of students should be in the order that they registered.- a method to remove a student from the course. if the student is not found, then an exception with an appropriate message should be raised (use the same exception class mentioned a method that will allow course objects to be output to a file using object serialization- a method that will allow course objects to be read in from a file created with object serializationyou will note that the student and instructor classes described above have some commonality. create aperson class that captures this commonality and uses it as a base class for student and instructor. this class should be responsible for the name and id fields and also provide atostring method that returns a string of the form name, id. this will be the inheritedtostring method for the student and instructor classes.1. draw a uml diagram for diss application.2. implement the previous classes in java. write a main program that can serve as a test class that tests all of the methods created and demonstrates that they are working
Answers: 2
question
Computers and Technology, 23.06.2019 13:30
What is the primary difference between the header section of a document and the body? a. the body is displayed on the webpage and the header is not. b. the header is displayed on the webpage and the body is not. c. the tag for the body is self-closing, but the tags for the headers must be closed. d. the tag for the header is self closing, but the tag for the body must be closed.
Answers: 3
question
Computers and Technology, 24.06.2019 04:30
Which of the following terms refers to a collection of different types of software that share the goal of infiltrating a computer and making it do something? a- malware b- virus c- spyware d- trojan horse
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, 21.04.2021 02:40
question
Mathematics, 21.04.2021 02:40
question
Mathematics, 21.04.2021 02:40
question
Mathematics, 21.04.2021 02:40
question
Mathematics, 21.04.2021 02:40
question
Health, 21.04.2021 02:40
Questions on the website: 13722362