I am trying to solve a programming problem and have only partially achieved this; I need to optimize the solution - and what you enter. First, the parameters are:
int x1, y1, x2, y2
int px, py = INT_MAX
px, py
px
So what I thought:
int xtop, ytop, xbot, ybot
ybot
imin
lines[i].ybot >= py
i < imin
yi = kx + m
px, py = lines[i].{x, y}bot
The problem is that this time complexity & in; ? theta; (n 2 ) - IOW, this sucks for large inputs.
One idea is to use something like kd tree , but then the question arises whether it would be very expensive to calculate which lines go into the so-called half-spaces.
, . , , ; , , 2n + 1 . , , . , , , , , ( ); : O (log n) -time.
. x-. . . , , . , , , O (n log n) O (n ^ 2), - - , .
: O (n log n).
Source: https://habr.com/ru/post/1527535/More articles:jQuery selector all identifiers that are integers - javascriptSVG height element not dynamic? - htmlConvert integer to null binary string - javamvn release: run does not deploy release version - javaMultipeer audio streaming stops running in the background - objective-chow to print variable name and value using scala macro? - scala-macrosОшибка компилятора QtPropertyBrowser при добавлении файла moc_objectcontroller.cpp в исходное дерево Visual Studio - propertiesWhat is the best way to query a JPA object for instances based on current date + time? - javaLibgdx Rendering Textures vs Sprites - androidSublime Text plugin API: how to get a list of files in a project? - sublimetext2All Articles