Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. Step 2 of Algorithm ANY-SEGMENTS-INTERSECT from Lecture 10 sorts the endpoints of the seg- ments in S from left to right. Why does it
2. Step 2 of Algorithm ANY-SEGMENTS-INTERSECT from Lecture 10 sorts the endpoints of the seg- ments in S from left to right. Why does it have to break ties by always putting left endpoints before right endpoints with the same c-coordinate in the sorted list? (2 marks) Algorithm ANY-SEGMENTS-INTERSECT(S), ANY-SEGMENTS-INTERSECT(S) 1 TO 2 sort the endpoints of the segments in S from left to right, breaking ties by putting left endpoints before right endpoints and breaking further ties by putting points with lower y-coordinates first 3 for each point p in the sorted list of endpoints do if p is the left endpoint of a segments then INSERT(T, s) if (ABOVE(T, ) exists and intersects s) or (BELOW (T, s) exists and intersects s) then return TRUE if p is the right endpoint of a segments then if both ABOVET, s) and BELOW (T, s) exist and ABOVET, ) intersects BELOW(Ts) then return TRUE DELETE(T, ) 12 return FALSE Time complexity: Line 2 takes O(nlg n) time. The for-loop has
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started