Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve the solution in C + + code & also see the image. Problem 2 : Given a set of n rectangles on x
Please solve the solution in C code & also see the image.
Problem : Given a set of n rectangles on xaxis, remove the hidden lines to mark the boundary only.
Follow:
Input is sorted in nondescending order of startX
Input:
Hidden Line Removal: Output
Follow:
Output is sorted in ascending order of X
Hidden Line Removal: Sweep Line Algorithm
Follow:
Input is sorted in nondecreasing order of startX
s
e
s
e
s
e
s
e
s
e
Hidden Line Removal: Algorithm
Follow:
Input is sorted in nondecreasing order of startX
Sort Xcoordinates
s
s
e
e
s
s
e
s
e
e
Hidden Line Removal: Algorithm
Maximum Height Heap
Scan the points from left to right, and insertdelete heights intofrom MaxHeap as follows:
s
s
e
e
s
s
e
s
e
e
Hidden Line Removal: Algorithm
Maximum Height Heap Point
Start points are inserted into the heap. If the maximum height changes, then the point belongs to the boundary
s
s
e
e
s
s
e
s
e
e
Hidden Line Removal: Algorithm
Maximum Height Heap Point
Start points are inserted into the heap. If the maximum height changes, then the point belongs to the boundary
s
s
e
e
s
s
e
s
e
e
Hidden Line Removal: Algorithm
Maximum Height Heap
End points are deleted from the heap. If the maximum height changes, then the point belongs to the boundary
s
s
e
e
s
s
e
s
e
e
Hidden Line Removal: Algorithm
Maximum Height Heap Point
End points are deleted from the heap. If the maximum height changes, then the point belongs to the boundary
s
s
e
e
s
s
e
s
e
e
Hidden Line Removal: Algorithm
Maximum Height Heap Point
Start points are inserted into the heap. If the maximum height changes, then the point belongs to the boundary
s
s
e
e
s
s
e
s
e
e
Hidden Line Removal: Algorithm
Maximum Height Heap Point
Start points are inserted into the heap. If the maximum height changes, then the point belongs to the boundary
s
s
e
e
s
s
e
s
e
e
Hidden Line Removal: Algorithm
Maximum Height Heap Point
End points are deleted from the heap. If the maximum height changes, then the point belongs to the boundary
s
s
e
e
s
s
e
s
e
e
Hidden Line Removal: Algorithm
Maximum Height Heap Point
Start points are inserted into the heap. If the maximum height changes, then the point belongs to the boundary
s
s
e
e
s
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started