Assingnment CS502 1
Assingnment CS502 1
Uploading instructions
For clarity and simplicity, you are required to upload/submit only one .doc/docx file.
Lectures:
The following is a set of 2-dimension space points. Each point has its x and y coordinate.:
P= {(2,11), (3,4), (5,9), (5,3),(6,8),(9,6),(12,4),(13,10),(14,8),(15,6)}
and the plane sweep algorithm pseudo code.
PLANE-SWEEP-MAXIMA(n, P[1..n])
sort P in increasing order by x;
stack s;
for i ← 1 to n
do
do s.pop();
s.push(P[i]);
You have to find out the final maximal set of points from given set of 2-dimension space point P = {p1, p2,p3,p4,p5,
…………… ,pn} using plane sweep algorithm and store it in a stack in sorted order by sweeping a vertical line from
left to right on x axis. The starting status of sweep line and stack is provided in the image. You have to follow it
and show the updated stack status in each step and the final image of the maximal set of points with stack
from left to right in the graph as well.
Note: In a given set of n points, P = {p1, p2, . . ., pn}, In 2-dimensional space a point is said to be maximal if it is
not dominated by any other point in P. The problem is to output all the maximal points of P.
Total
: 20
ANS: • Sorting Points: Imagine these points are scattered randomly on your paper.
We start by organizing them from left to right based on their x-coordinates. This
just helps us keep things in order.
• Starting with an Empty Pile: Now, picture a pile of papers (let's call them
"point papers") next to your points. At the beginning, this pile is empty.
• Take the first point from your organized list. Put its paper on top of the pile.
• If the next point's y-coordinate is higher than the top paper on the pile, take off
papers from the top until you find a paper that has a lower y-coordinate or until the
pile is empty. Then put the new paper on top.
• Final Pile: After going through all the points like this, the pile will have papers
representing the highest points at each horizontal position. These papers are the
maximal points because there's no other paper above them at the same horizontal
position.
• Graphical View: Imagine you looking at this on a graph. The points on the pile
are the ones you would see if you drew a vertical line from left to right on the
graph, keeping only the highest points at each x-coordinate.