NOTE: All the operations should be implemented by searching the quadtree (brute force solutions are not acceptable). Also note that for any operation that is not implemented you should output the message: COMMAND IS NOT IMPLEMENTED Operation 9 - TOUCH(N) Input: N is the name of a rectangle (need not necessarily be in the MX-CIF quadtree) Output: For every rectangle M that N touches (has a common side or corner) print N SHARES ENDPOINT (,) WITH If M shares a line with N then print the coordinates of the point with the minimum (X,Y) values (the bottom-leftmost point). The order of the rectangles does NOT matter If no rectangle of the MX-CIF quadtree touches N then print TOUCH: ZERO RECTANGLES FOUND Operation 10 - WITHIN(N,D) Input: N is the name of a rectangle (inside the database and not necessarily in the quadtree) D is an integer Output: For every rectangle M that satisfies the search criteria (see the project description for more details) print: WITHIN (,) The order of the rectangles does NOT matter If no rectangle of the MX-CIF quadtree is within N then print WITHIN: ZERO RECTANGLES FOUND Operation 11 - HORIZ_NEIGHBOR(N) VERT_NEIGHBOR(N) Input: N name of a rectangle inside the database. Output: IS HORIZONTAL NEIGHBOR OF or IS VERTICAL NEIGHBOR OF where M is the nearest neighbor of N, whose distance is STRICTLY greater than zero. Note that if the two rectangles touch along a corner the distance IS ZERO. In the case where there is no rectangle with distance greater than zero in the quadtree you should return: HORIZONTAL(VERTICAL) NEIGHBOR OF NOT FOUND If more than one rectangle is at the same distance, then you should print just one. Operation 12 - NEAREST_RECTANGLE(PX,PY) Input: PX and PY are real numbers. Output: IS THE NEAREST RECTANGLE TO (,) where M is the rectangle with the "minimum distance" from PX,PY. The distance between a rectangle and a point is defined as the minimum distance between the point and a corner or a side of the rectangle. If the point is inside the rectangle then the distance is zero. If more than one rectangle is at the same distance, then you should print just one. If no rectangle is found then print NEAREST_RECTANGLE: ZERO RECTANGLES FOUND Operation 13 - WINDOW(LLX, LLY, LX, LX) Input: LLX, LLY, LX, LY are integers. Output: START WLIST ... START DISPLAY ... END DISPLAY END WLIST Note that the rectangles must be completely inside the window. Also note that the printing order is not important as long as all the rectangles that are inside and only them are displayed. If no rectangle is totally inside the window then print START WLIST END WLIST OPTIONAL OPERATIONS Numbering convention For the first two operations you will have to use the following numbering schema for the nodes of the quadtree: -The root of the tree is number 0 -If a node is number N then the NW,NE,SW and SE childen of this node are 4*N+1, 4*N+2, 4*N+3 and 4*N+4 respectively. For example, starting at the root the NE child is numbered 2, while the SE child of the NW child of the root (Root->NW->SE) is numbered 4*(4*0+1)+4=8 Operation 14 - NEAREST_NEIGHBOR(N) Input: N name of a rectangle inside the database. Output: NEAREST NEIGHBOR OF : M is the name of the nearest rectangle inside the quadtree. The list contains the numbers of the nodes that are extracted from the priority queue if you are using the incremental nearest neighbor algorithm, or the order of the traversal of the quadtree if you are using another approach. In any case the first element of the list is always 0 (the root node of the quadtree). If more than one rectangle is at the same distance, then return the name of just one of them. If no rectangle is found then print NEAREST_NEIGHBOR: ZERO RECTANGLES FOUND Operation 15 - LEXICALLY_GREATER_NEAREST_NEIGHBOR(N) Input: N is the name of the rectangle inside the database Output: LEX GREATER NEAREST NEIGHBOR OF : M is the name of the nearest neighbor of N that has a lexicographically greater name. The list can contain numbers that represent nodes of the MX-CIF quadtree but it can also contain the names of the rectangles that are closer than M but their names are less than N. Again, you should print the list in the order which the elements are extracted from the priority queue. So the first element of the list should be number 0 that is the root of the MX-CIF quadtree. Note that for this operation you have to use the incremental nearest neighbor algorithm. If no rectangle is found then print LEXICALLY_GREATER_NEAREST_NEIGHBOR: ZERO RECTANGLES FOUND Operation 16 - LABEL() Input: None Output: START DISPLAY END DISPLAY In this display, all touching rectangles should be shown with the same label.