Search for question
Question

Exercise 1:

In the attached scaffold file extremes.py, complete the implementation of the Pt2dset class and its documentation, following the guidelines below:

- An object of the class Pt2dset represents a set of points in the 2D plane. It has one private data attribute, which is a list of Pt2d objects. The elements of the list are instantiated using the data from the argument to the Pt2dset constructor, which should be in one of the following forms:

• a list of pairs where each pair (x,y) contains the coordinates of a point e.g. [(1.5, 5),

(-8.2, 1.4), (3.6, 7.3), (-2.5, 5.4)]

• a list of dictionaries where each dictionary has the two keys 'x' and 'y' e.g. [{'x' :

1.5, 'y' 5}, {'x': -8.2, 'y' : 1.4}, {'x' : 3.6, 'y' 7.3},

{'x' -2.5, 'y' 5.4}]

(point coordinates defined in another format may -or may not- be successfully used).

The constructor may take no argument at all, in which case, the set of points will be empty.

- The axes of the Cartesian referential split the 2D plane into four quadrants. The quadrants() method, of the Pt2dset class, returns a list (of strings) describing the quadrants of the 2D plane containing points from the set. Possible elements of the returned list are: 'top-right', 'bottom-right', 'bottom-left', 'top-left'.

- A point (x₁, y₁) in the Cartesian plane is said to be dominated by point (x,y;), if the two pints are distinct, x₁ < x; and y₁ ≤ y₁. Given a set of n points, one of them is said to be an extreme of the set, if it is not dominated by any other point in the set. For example, in the figure below, all the extreme points of the set of 10 points are circled.