Answer the question
In order to leave comments, you need to log in
How to find the maximum between two points on a discrete graph?
given a graph of points. It is necessary to find the maximum value between any two points (including these extreme points themselves).
The task is programmatic, so any "meta-information" necessary for calculations can be added to each point. Those. data can be prepared by initially adding some meta-information (if needed).
I can't store the maximums for all combinations, because there are more than a million points, and there will be too many combinations.
Those. at the input of the program - two points (with values at these points and meta-information). I only need to get the maximum based on these data.
Example:
Let's take a pair of points with serial numbers {1,4}. Here the maximum value between them = 4.
Let's take a pair of points with serial numbers {4,5}. Here the maximum value between them = 3.
Are there any algorithms for this? Can this be done at all?
Answer the question
In order to leave comments, you need to log in
At each point, store an array of maximums to the right of it. Then search until the end of the interval to find the value.
1:{1:1, 2:2, 3:4}
2:{2:2, 3:4}
3:{3:4}
4:{4:0.3, 5:3}
5:{5:3 }
6: {6: 1}
{1, 4} => Take the array at point 1, move along it, the nearest less than 4 - 3. Maximum 4.
Come on, don't call your drawing discrete! There is a section in mathematics related to vectors, the formulas there are simple and do not require a lot of computer resources
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question