

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Karki; Class: ADV DATA STRUCTURES; Subject: Computer Science; University: Louisiana State University; Term: Fall 2009;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CSC 3102 Programming Assignment 3 Convex Hull Problem Due: November 17, Tuesday (by 11:55 pm) Points: 5 plus a bonus of 2. Penalty: You will lose one point per delayed day Submit your work as instructed towards the end of this document. Contact TA Di Lin by e- mail to [email protected] or me by e-mail to [email protected] for help. Objective: Implement an algorithm to find a convex hull for given sets of points on a plane. Background: The convex-hull problem is the problem of finding the smallest convex polygon (that is, convex hull) that contains a given set of n points in the plane. In the class, we have discussed two algorithms for solving the problem. The brute-force algorithm (section 3.3 of the text book and the lecture note) is based on the fact that a line segment connecting any two points of a given set of n points is a part of the convex hull’s boundary if and only if all the other points of the set lie on the same side of the straight line through these two points. This requires checking whether the expression (ax + by – c) has the same sign (including zero) at each of these points. On the other hand, the quickhull algorithm is based on the divide-and-conquer approach (see section 4.6 of the text book and the lecture note). The algorithm assumes that the points are sorted in an increasing order of their x-coordinates and then y-coordinates. The line joining the leftmost and rightmost points (P 1 Pn) separates the points into two sets: The set of points to the left of the line results in the upper boundary called upper hull and the other set of points to the right of the line results in the lower boundary called lower hull. Both hulls are constructed using recursive approach as discussed in the book and the lecture note. One can check whether a point lies to the left of a line determined by two other points by computing the determinant formed by three points. Project task: Implement either the brute-force algorithm or the quickhull algorithm to solve the convex hull problem using the language of your choice. This is for 5 points. Implement both the algorithms to get a bonus of 2.5 points. You can use a simple array data structure. The first input array contains a set of n = 15 points on the xy-plane as follows: Data1(x, y): (1, 4), (2, 5), (2, 6), (3, 14), (4, 1), (5, 3), (5, 6), (7, 2), (7, 5), (7, 10), (9, 3), (9, 12), (12, 1), (12, 7), (14, 6) The second input array contains a set of n = 30 points on the xy-plane as follows: Data2(x, y): (2, 1), (2, 4), (3, 6), (3, 9), (4, 3), (6, 5), (6, 6), (6, 14), (7, 5), (7, 11), (8, 6), (9, 4), (12, 4), (12, 9), (15, 2), (16, 1), (16, 14), (18, 8), (18, 21), (19, 3), (19, 15), (21, 6), (22, 6), (22, 20), (23, 3), (23, 16), (25, 13), (26, 7), (26, 19), (28, 4) Output: Your program output should list the points (their x- and y- coordinates) in pairs of A and B, which define the line segments of the convex hull’s boundary you are constructing. For Data1, the convex hull is made up of six line segments: A B (1, 4) (3, 14) (1, 4) (4, 1) (3, 14) (9, 12)
Alternatively, you can simply list the extreme points, i.e., those points that form the convex hull in the order algorithm (particularly, quickhull) finds them. For Data1, the convex hull is made up of six points: (1, 4) (14, 6) (3, 14) (9, 12) (12, 1) (4, 1) Also compute the total number, C(n), of times the basic operation is executed by putting a counter in appropriate place within the innermost loop. Find the ratio of the counts for two given input arrays and explain how the time efficiency depends on the input size, n. Do this for both algorithms to get the bonus points. Submitting Your Work: Create a directory prog3 in your main directory on “classes” machine. All files you submit must have a header with the following: Name: Your Name File: filename.ext Instructor: Bijaya B Karki Class and section: cs3102. LogonID: cs3102xx Submit your assignment to the grader with the following command: /classes/cs3102/cs3102_kar/bin/p_copy 3 This command copies everything in your prog3 directory including readme. You need to create a directory called prog3 in your “classes” account. Once p_copy 3 is finished, check to see if all required files have been submitted: /classes/cs3102/cs3102_kar/bin/verify 3