Question: Line segments and polygons are used to model geometric objects in computer graphics, video games, and computer-aided design, often in data pipelines that use the

Line segments and polygons are used to model geometric objects in computer graphics, video games, and computer-aided design, often in data pipelines that use the output of one program as the input to another. One complication that can arise in such scenarios is that a data format needed for the input to the second system may be missing from the output from the first. For instance, one program may output an object as an unordered set of line segments but the other may require its input to be defined by a polygon. So, suppose you are given a set, S, of n line segments, in no particular order. Describe an efficient algorithm for determining whether the segments of S form a polygon, P, and if so, give a polygonal representation for P. You may allow P to be non-simple (that is, selfintersecting), but P must be a single cyclical chain of distinct vertices connected by the segments in S. What is the running time of your algorithm?

Step by Step Solution

3.36 Rating (171 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

By a sorting step on the segment endpoints we can determine t... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Data Structures Algorithms Questions!