
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Spring 2002 http://www.cs.umd.edu/class/spring2002/cmsc420/ HOMEWORK 2: Due April 2, 2002
Suppose you have a text file called RectInwhere each line in the text file contains information about a rectangle. A line in the text file has the format
RectangleID LLx LLy URx URy
This information says that there is a rectangle named RectangleId (string type) hose lower left corner is (LLx; LLy) and whose upper right corner is (URx; URy). LLx; LLy; URx; URy are all integers. You are required to write an algorithm called find-intersections. What the algorithm does is to take a file RectIn of the above kind as input and it returns as output, a file RectOut having the same structure. The contents of the output file are determined as follows. If there are two distinct rectangles r 1 ; r 2 in RectIn that intersect, then the output must contain a rectangle describing the in- teresction of r 1 and r 2 (note that the intersection of two rectangles is also a rectangle). The rectangle obtained in this way should have the name r 1 : r 2. Your output file must not contain any redundant or unnecessary information (i.e. all rectangles in the output must be the intersection of two rectangles in the input and the intersection must not be empty).