Software Construction Course Experience (2)

The want to look at another solution on the experimental method in the convex hull of a

I in the original experiment using a point to draw the angle between the convex hull, the angle of each minimum point taken was added convex set, so that one can construct comprise the entire set of points. Used the time complexity is square n, it solves the problem, the time complexity is not satisfactory, I will describe below a time complexity of n method.

We can use the divide and conquer algorithm, the whole of a major problem, split into two smaller problems, namely the n points into two n / 2 points so there is a problem T (n) = 2T (n / 2) +?
in order to merge two sub-problems, we need to draw the two have a convex n / 2 points Figure combined into a convex n points to draw the map
for which we need to remove some of the old connection , and increase the number of connection points to draw the convex n. In fact, after a simple analysis we can know, we have to add the line there are only two, one in a, b upper end cap, a in a, b lower end of the back cover, then deleting this time surrounded by the line on the line, and difficult to how do we find that the two lines to be added.
And this "?" Is the time we needed to merge two sub-problems, we have to reduce him as much as possible.

We now set up two small problems are a, b (a and b point in the point is not located on the same side)
general idea is naturally I will be a connection with the b each two points, if the figure All points are on one side of the line, then we can determine, this is a line of convex. But this time we complexity or square n, there is no progress.

Algorithm: Since a and b are not in the same side, so that we can draw a straight line, the left side of this line is a point, the point b is the right side. We find the two points with a a1 b is closest to this line, b1, and the two-dot chain line, and the obtained straight line a1b1 necessarily have an intersection, we note the location of this point, and then moving the a point becomes the a1 (a2, a3) being connected to two points a1, if the intersection of the straight line a2b1 or a1b1 is higher than the intersection of a straight line, then replace the A3B1 a1 and replaced with the intersection of the current the highest line, if we are to retain a1 a1 higher than the other two intersections, then move b1, moving a1 same methods and, if a1b1 is currently already the highest in the segment, and then we found our a1b1 is convex in one, so we found a line capped. As for the back cover of the line, we are looking for is the lowest straight line segment can focus the same way.

This algorithm is clever in the consolidated sub-problem when each traverse point at most once, time complexity is reduced to n

Released three original articles · won praise 0 · Views 40

Guess you like

Origin blog.csdn.net/wzj1212123/article/details/104682942