Question: Using C++, data structures, C++ STL, all test inputs and outputs are shown below. Finding the convex hull of a set of points is an

Using C++, data structures, C++ STL, all test inputs and outputs are shown below.

Finding the convex hull of a set of points is an important problem that is often part of a larger problem. There are many algorithms for finding the convex hull. Since problems involving the convex hull sometimes appear in the ACM World Finals, it is a good idea for contestants to know some of these algorithms.

Finding the convex hull of a set of points in the plane can be divided into two sub-tasks. First, given a set of points, find a subset of those points that, when joined with line segments, form a convex polygon that encloses all of the original points. Second, output the points of the convex hull in order, walking counter-clockwise around the polygon. In this problem, given a set of points, you are required to write a program to construct the convex hull.

Using C++, data structures, C++ STL, all test inputs and outputs are

Input Specification The first line of input contains a single integer, the number of test cases to follow. The first line of each test case contains a single integer 3

Sample Input 1 5 1 1 1 -1 0 0 -1 -1 2 -1 1

Output Specification For each test case, generate the following output. First, output a line containing a single integer m, the number of points on the convex hull. Next output m lines, each describing a point on the convex hull, in counter-clockwise order around the hull. Each of these lines should contain the x-coordinate of the point, followed by a space, followed by the y-coordinate of the point. Start with the point on the hull whose x-coordinate is minimal. If there are multiple such points, start with the one whose y-coordinate is minimal.

Output for Sample Input 4 -1 -1 1 -1 1 1 -1 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!