Daniel S. Roche
2011-07-17 21:34:00 UTC
Hi class,
Some students are asking about how to handle duplicate keys in the
RangeSkip class. Note that the underlying (included) SkipList class does
handle duplicate keys seamlessly, just by having separate nodes
(SkipTowers) for each time the key is repeated.
There are at least two good reasons why your RangeSkip class should also
handle duplicate x values in the keys:
1) Since we have two-dimensional data, two keys could be distinct but
have identical x-coordinate. For instance, the points (1,2) and (1,3).
2) The keys here are approximate values (type double), so the question
of equality becomes much less clear anyway. For instance, if the points
represent geographical coordinates, we might have two different cities
that are very close together, so their (imprecise) coordinates are the
same even though they should be distinct.
However, for the purposes of auto-marking your assignment, I will be
very nice and promise that all points are in *general position*, meaning
the the x-coordinates AND the y-coordinates of any two distinct points
will always be different. So for instance we won't test with points
(1,2) and (1,3), or with points (4,5) and (6,5), or with points (0,2)
and (0,2).
So although you should handle duplicate x and y coordinates, and I
actually think the code is simpler if this is handled correctly, you
don't have to in order to receive full marks for this assignment.
-Dan Roche
CS 240 Instructor, Section 003
Some students are asking about how to handle duplicate keys in the
RangeSkip class. Note that the underlying (included) SkipList class does
handle duplicate keys seamlessly, just by having separate nodes
(SkipTowers) for each time the key is repeated.
There are at least two good reasons why your RangeSkip class should also
handle duplicate x values in the keys:
1) Since we have two-dimensional data, two keys could be distinct but
have identical x-coordinate. For instance, the points (1,2) and (1,3).
2) The keys here are approximate values (type double), so the question
of equality becomes much less clear anyway. For instance, if the points
represent geographical coordinates, we might have two different cities
that are very close together, so their (imprecise) coordinates are the
same even though they should be distinct.
However, for the purposes of auto-marking your assignment, I will be
very nice and promise that all points are in *general position*, meaning
the the x-coordinates AND the y-coordinates of any two distinct points
will always be different. So for instance we won't test with points
(1,2) and (1,3), or with points (4,5) and (6,5), or with points (0,2)
and (0,2).
So although you should handle duplicate x and y coordinates, and I
actually think the code is simpler if this is handled correctly, you
don't have to in order to receive full marks for this assignment.
-Dan Roche
CS 240 Instructor, Section 003