Answered step by step
Verified Expert Solution
Link Copied!

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 2: Given a set of n rectangles on x-axis, remove the hidden lines to mark the boundary only.
**Follow:
Input is sorted in non-descending order of startX
Input:
<3,7,10>
<5,9,12>
<12,20,5>
<13,15,15>
<19,22,8>
**Hidden Line Removal: Output
Follow:
Output is sorted in ascending order of X
<3,10>
<5,12>
<9,0>
<12,5>
<13,15>
<15,5>
<19,8>
<22,0>
**Hidden Line Removal: Sweep Line Algorithm
Follow:
Input is sorted in non-decreasing order of startX
<3,10, s>
<7,10, e>
<5,12, s>
<9,12, e>
<12,5, s>
<20,5, e>
<13,15, s>
<15,15, e>
<19,8, s>
<22,8, e>
** Hidden Line Removal: Algorithm
Follow:
Input is sorted in non-decreasing order of startX
Sort X-coordinates
<3,10, s>
<5,12, s>
<7,10, e>
<9,12, e>
<12,5, s>
<13,15, s>
<15,15, e>
<19,8, s>
<20,5, e>
<22,8, e>
**Hidden Line Removal: Algorithm
Maximum Height =0 Heap ={0}
Scan the points from left to right, and insert/delete heights into/from Max-Heap as follows:
<3,10, s>
<5,12, s>
<7,10, e>
<9,12, e>
<12,5, s>
<13,15, s>
<15,15, e>
<19,8, s>
<20,5, e>
<22,8, e>
** Hidden Line Removal: Algorithm
Maximum Height =10 Heap ={10,0} Point =(3,10)
Start points are inserted into the heap. If the maximum height changes, then the point belongs to the boundary
<3,10, s>
<5,12, s>
<7,10, e>
<9,12, e>
<12,5, s>
<13,15, s>
<15,15, e>
<19,8, s>
<20,5, e>
<22,8, e>
**Hidden Line Removal: Algorithm
Maximum Height =12 Heap ={12,10,0} Point =(5,12)
Start points are inserted into the heap. If the maximum height changes, then the point belongs to the boundary
<3,10, s>
<5,12, s>
<7,10, e>
<9,12, e>
<12,5, s>
<13,15, s>
<15,15, e>
<19,8, s>
<20,5, e>
<22,8, e>
** Hidden Line Removal: Algorithm
Maximum Height =12 Heap ={12,0}
End points are deleted from the heap. If the maximum height changes, then the point belongs to the boundary
<3,10, s>
<5,12, s>
<7,10, e>
<9,12, e>
<12,5, s>
<13,15, s>
<15,15, e>
<19,8, s>
<20,5, e>
<22,8, e>
** Hidden Line Removal: Algorithm
Maximum Height =0 Heap ={0} Point =(9,0)
End points are deleted from the heap. If the maximum height changes, then the point belongs to the boundary
<3,10, s>
<5,12, s>
<7,10, e>
<9,12, e>
<12,5, s>
<13,15, s>
<15,15, e>
<19,8, s>
<20,5, e>
<22,8, e>
** Hidden Line Removal: Algorithm
Maximum Height =5 Heap ={5,0} Point =(12,5)
Start points are inserted into the heap. If the maximum height changes, then the point belongs to the boundary
<3,10, s>
<5,12, s>
<7,10, e>
<9,12, e>
<12,5, s>
<13,15, s>
<15,15, e>
<19,8, s>
<20,5, e>
<22,8, e>
** Hidden Line Removal: Algorithm
Maximum Height =15 Heap ={15,5,0} Point =(13,15)
Start points are inserted into the heap. If the maximum height changes, then the point belongs to the boundary
<3,10, s>
<5,12, s>
<7,10, e>
<9,12, e>
<12,5, s>
<13,15, s>
<15,15, e>
<19,8, s>
<20,5, e>
<22,8, e>
**Hidden Line Removal: Algorithm
Maximum Height =5 Heap ={5,0} Point =(15,5)
End points are deleted from the heap. If the maximum height changes, then the point belongs to the boundary
<3,10, s>
<5,12, s>
<7,10, e>
<9,12, e>
<12,5, s>
<13,15, s>
<15,15, e>
<19,8, s>
<20,5, e>
<22,8, e>
** Hidden Line Removal: Algorithm
Maximum Height =8 Heap ={8,5,0} Point =(19,8)
Start points are inserted into the heap. If the maximum height changes, then the point belongs to the boundary
<3,10, s>
<5,12, s>
<7,10, e>
<9,12, e>
<12,5, s>
<13,1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions

Question

What is a NIC? What is a hub?

Answered: 1 week ago