Spring 2024 - CS502 - 1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Assignment No.

01
Spring 2024 Total Marks: 20
CS502- Fundamentals of Algorithms

Due Date: 29-04-2024

Instructions

Please read the following instructions carefully before solving & submitting assignment:

It should be clear that your assignment will not get any credit (zero marks) if:
 The assignment is submitted after due date.
 The submitted assignment is other than MS Word file.
 The submitted assignment does NOT open or file is corrupted.
 The assignment is copied (from other student or ditto copy from handouts or internet).

Uploading instructions

 For clarity and simplicity, you are required to upload/submit only one .doc/docx file.

Lectures:

 Lectures 1 to 10 are covered in this assignment.

Objectives

 The objectives of this assignment are;

 To be able to understand concept of maximal point calculation in an efficient way by using plane sweep
algorithm.
 To be able to understand the concept of plane sweep Algorithm and its working.

For any query about the assignment, contact at CS502@vu.edu.pk

Good Luck!
Question No. 1 Marks: 20

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

 while (s.notEmpty() & s.top().y ≤ P[i].y)

 do s.pop();

 s.push(P[i]);

 output the contents of stack.

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 Marks: 20

You might also like