Given a fixed set of points. We need to find convex hull of given set. We also need to find convex hull when a point is removed from the set.
Initial Set of Points: (-2, 8) (-1, 2) (0, 1) (1, 0) (-3, 0) (-1, -9) (2, -6) (3, 0) (5, 3) (2, 5) Initial convex hull:- (-2, 8) (-3, 0) (-1, -9) (2, -6) (5, 3) Point to remove from the set : (-2, 8) Final convex hull: (2, 5) (-3, 0) (-1, -9) (2, -6) (5, 3)
Prerequisite : Convex Hull (Simple Divide and Conquer Algorithm)
The algorithm for solving the above problem is very easy. We simply check whether the point to be removed is a part of the convex hull. If it is, then we have to remove that point from the initial set and then make the convex hull again (refer Convex hull (divide and conquer) ).
And if not then we already have the solution (the convex hull will not change).
convex hull: -3 0 -1 -9 2 -6 5 3 2 5
It is simple to see that the maximum time taken per query is the time taken to construct the convex hull which is O(n*logn). So, the overall complexity is O(q*n*logn), where q is the number of points to be deleted.
This article is contributed by Amritya Vagmi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Closest Pair of Points using Divide and Conquer algorithm
- Convex Hull | Set 1 (Jarvis's Algorithm or Wrapping)
- Convex Hull | Set 2 (Graham Scan)
- Closest Pair of Points | O(nlogn) Implementation
- Find Simple Closed Path for a given set of points
- Orientation of 3 ordered points
- Count Integral points inside a Triangle
- Number of Integral Points between Two Points
- Non-crossing lines to connect points in a circle
- Count maximum points on same line
- Circle and Lattice Points
- Queries on count of points lie inside a circle
- Quickhull Algorithm for Convex Hull
- Minimum lines to cover all points
- How to check if given four points form a square