subject
Computers and Technology, 01.12.2020 16:40 zay179

In C++, Write a class Field. h and Field. cpp that stores a 2-D array of integers. The following methods should be implemented:
Field( const vector> & )
Field( vector> && )
int Weight( int x1, int y1, int x2, int y2 )
This method returns the sum of all elements in the rectangle defined by the points (x1,y1) and (x2,y2).
Pay attention, the relative position of (x1,y1) and (x2,y2) can be any. If coordinates go beyond the array boundaries, throw the out_of_range exception.
The Weight function should be O(1) run time. To achieve this, you will need to do the precomputing in the constructors. Precomputing should be done in O(N) time and O(N) space. Here, N is the total number of the elements in the 2-D array.
For example, for the array below function Weight(1,2,4,0) returns 42. The selected rectangle is highlighted.
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
int PathCost()
This method computes the cost of the cheapest path from top-left corner of the field to the bottom-right corner. The only possible moves are right and down.
The function PathCost should be O(N) time.
For example, for the same 2-D array, PathCost() returns 25. The cheapest path is highlighted on the picture below.
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
Requirement: no explicit usage of pointers anywhere in your code please. Please comment code thoroughly as well.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 10:20
Write a program that keeps asking the user for new values to be added to a list until the user enters 'exit' ('exit' should not be added to the list). these values entered by the user are added to a list we call 'initial_list'. then write a function that takes this initial_list as input and returns another list with 3 copies of every value in the initial_list. finally, inside print out all of the values in the new list. for example: input: enter value to be added to list: a enter value to be added to list: b enter value to be added to list: c enter value to be added to list: exit output: a b c a b c a b c note how 'exit' is not added to the list. also, your program needs to be able to handle any variation of 'exit' such as 'exit', 'exit' etc. and treat them all as 'exit'.
Answers: 2
question
Computers and Technology, 24.06.2019 15:00
Universal windows platform is designed for which windows 10 version?
Answers: 1
question
Computers and Technology, 24.06.2019 18:00
Explain the circumstances for which the interquartile range is the preferred measure of dispersion. what is an advantage that the standard deviation has over the interquartile range? choose the correct answer below. a. the interquartile range is preferred when the distribution is symmetric. an advantage of the standard deviation is that it increases as the dispersion of the data increases. b. the interquartile range is preferred when the data are not skewed or no have outliers. an advantage of the standard deviation is that it uses all the observations in its computation. c. the interquartile range is preferred when the distribution is symmetric. an advantage of the standard deviation is that it is resistant to extreme values. d. the interquartile range is preferred when the data are bell shaped. an advantage of the standard deviation is that it is resistant to extreme values. e. the interquartile range is preferred when the data are skewed or have outliers. an advantage of the standard deviation is that it uses all the observations in its computation. f. the interquartile range is preferred when the data are bell shaped. an advantage of the standard deviation is that it increases as the dispersion of the data increases.
Answers: 2
question
Computers and Technology, 24.06.2019 21:30
How is a wan different than a lan? both connect computers, but only wan users don’t need the same operating system. both are peer-to-peer networks, but only a wan requires networking hardware. both network computers, but only a wan can cover larger geographical ranges. both connect computers to the internet, but only wan connects to the cloud.
Answers: 1
You know the right answer?
In C++, Write a class Field. h and Field. cpp that stores a 2-D array of integers. The following me...
Questions
question
Mathematics, 28.08.2019 03:30