0% found this document useful (0 votes)
41 views2 pages

ESO 207A Programming Assignment 2: Due On 09/02/2019: 1 Dominating Set in 2-D

This document describes a programming assignment to find the dominating set of points in 2D space. The problem asks to write a C program that takes a set of n points as input, and outputs the dominating set of those points using a divide and conquer algorithm with O(n log n) time complexity. It provides hints on using a subroutine Dom(i, j) to find the dominating set within a subset of points, and initially sorting the points by x-value. Sample input and output are given along with constraints on the input values.

Uploaded by

Kshitij Jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views2 pages

ESO 207A Programming Assignment 2: Due On 09/02/2019: 1 Dominating Set in 2-D

This document describes a programming assignment to find the dominating set of points in 2D space. The problem asks to write a C program that takes a set of n points as input, and outputs the dominating set of those points using a divide and conquer algorithm with O(n log n) time complexity. It provides hints on using a subroutine Dom(i, j) to find the dominating set within a subset of points, and initially sorting the points by x-value. Sample input and output are given along with constraints on the input values.

Uploaded by

Kshitij Jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ESO 207A Programming Assignment 2: Due on 09/02/2019

January 23, 2019

1 Dominating Set in 2-D


Given two points p, q in 2-D space, p is said to dominate q if px ≥ qx and py ≥ qy . Define a partial ordering on
the points of the 2-D space, , as follows: q  p if p dominates q.
Let S be a set of points in a 2-D space. Then Dom(S) denotes those members of S which are not dominated
by any other point in S, i.e., Dom(S) = {q ∈ S|q 6 p ∀ p ∈ R2 \ {q}}.
Example Dom({(2, 1), (3, 2), (2, 3), (1, 2)}) = {(3, 2), (2, 3)}.

2 Problem
Given a set S of n points in a 2-D plane, write a C program to compute Dom(S). Observe that a trivial algorithm
can be designed which has O(n2 ) time complexity. Your task is to use divide and conquer and design an algorithm
with O(n. log n) time complexity.

3 Details
Save all input points in an array A[.] at locations 0 to n − 1 and return the set Dom(S) in array B[.] in consecutive
locations, starting from 0. For simplicity, assume that all points have integer coordinates.
Initially store all points in a 2-D array P oint. If the i-th point is (xi , yi ), then P oint[0, i] = xi and P oint[1, i] =
yi . So index i uniquely identifies the point.
Array A and B are integer arrays and they only store the indices of the points. That is, if A[j] = i, then it is
referring to the point (P oint[0, i], P oints[1, i]). Same is true for B.
Hint1: Devise a subroutine Dom(i, j), i ≤ j, which computes the Dom({A[i], . . . , A[j]) and returns it in array
B in the consecutive locations starting from B[i].
Hint2: Initially sort the points in A in increasing order of their x-values.

4 I/O Format
• The first line of the input consists of an integer n denoting the number of points in set S.
• Next n lines will contain n points with each line containing two integers separated by a single space. First
number being the x-coordinate and the second the y-coordinate.
• The output must have integer m, the number of points in Dom(S), in the first line. Subsequently m lines
must have x and y coordinates of one point each, separated by a single space. The points must be sorted in
increasing order of x-values of the points.

Sample Input:

4
3 2
1 2 |
2 3
2 1

Corresponding Output:

1
2
2 3
3 2

Constraints:

1 ≤ n ≤ 105
0 ≤ x ≤ 105
0 ≤ y ≤ 105

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy