Convex-Hull (2D) incremental construction


Is there an incremental algorithm for convex-hull (in the plane) construction in O(nlogn) ?
That is, we add the points one by one, and each step takes O(logn) time (not amortized, but exactly).

Who is Participating?
Jose ParrotGraphics ExpertCommented:
Well, as far I know, there are several algorithms, with amortized times O(log n log log log n for insertion and  O(log n log log n)  for deletion); the naive O(n^2); the classic O(n), other for O(log^2 n); other with very small gain on O(log log n).

Riko Jacob's PhD thesis, Dynamic Planar Convex Hull of University of Aarhus,  Denmark, claims O(log n) worst case. I didn't accessed this paper.

As you are looking for "exact" O(log n), it seems to be Theta(log n). In such way,  parallel algorithm could be your answer. You may want take a look at


Sorry, that's amortized.
I don't think it can be exactly because you may have to remove O(n) points from the hull when you add a new point
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

slaviknAuthor Commented:
I saw an amortized one, that uses lower and upper binary trees.
Is there an easier algorithm?
Jose ParrotGraphics ExpertCommented:
Hi, slavikn ,

To achieve O(n log n) time, a really good approach is to divide the problem in two parts, upper and lower parts of the convex hull.
By finding the leftmost and the rightmost vertices of the given set, we have the ending vertices of each part.
To find such vertices, we use a O(n log n) sorting algorithm, say, merge-sort.
The finding of each vertice is actually O(n). The final result is O(n log n) + O(n) = O(n log n).

Below is an algorithm for the upper part of the convex hull.

Input: set P of points
Output: a list of convex hull points in clockwise order
   UpperList = empty set
   Sort points by x-coord, s.t. p1.x < p2.x < ... <pn.x
   Add point p1 to UpperList
   Add point p2 to UpperList
   for i=3,n
      append pi to UpperList
          while number of points in UpperList > 2
          last 3 points in UpperList don't make a RIGHT turn
              delete the middle of last 3 points from UpperList

Sort points ... is O(n log n)
Add points is linear: O(1)
The "while" loop is executed at least once, each time the "for" loop is executed. So O(n).
Each additional execution of the "while" loop results in exactly one point deletion.
So, again O(n), because we have n points and each one can deleted just once.
Then final time is O(n log n) + O(1) + O(n) + O(n), resulting in O(n log n).

For lower part is similar, except for direction which is from right to left.
This algorith is easy to implement, I don't know about an easer algorithm for convex hull.
Hope it helps.

slaviknAuthor Commented:
Thanks for the detailed explanation JoseParrot.
However, the algorithm I asked for was supposed to be pure incremental, that is without the O(nlogn) sorting in advance.
Eventually I've found a solution (well, nearly, as each step is O(logn) only in amortized...). It's here:
slaviknAuthor Commented:
By the way, I am still looking for a "pure" incremental algorithm with exact complexity of O(logn) in each step (not amortized). A very simple initialization is allowed.
Jose ParrotGraphics ExpertCommented:
Hi, slavikn,

The answer to
"Is there an incremental algorithm for convex-hull (in the plane)
 construction in O(nlogn) ?"
is: YES.

Below some of such algorithms:

Scan, by Graham, 1972
Starting from leftmost point P1, the algorithm has 2 steps:
1) Sorting angles from P1 to P2 until Pn, by Divide and Conquer: O(n log n)
2) Discovering next point, by Greedy approach (point by point): O(n).
Result is: O(n log n) + O(n) --> O(n log n)

Divide-and-Conquer, by Preparata and Hong, 1977

OTHERS variants, after that:
Monotone Chain, by Andrew, 1979
Incremental, by Kallay, 1984
Marriage-before-Conquest, by Kirkpatrick & Seidel, 1986

Kallay's incremental algorithm description follows. Rather than determine the hull by looking at the whole set of points at once, as in 1 and 2, Kallay's looks at a subset of the points and then increase the subset until it was the entire set. The minimum subset, of course, is a triangle. The points aren't sorted, but the hull construction complexity is O(n log n).

For a pretty complete article, you may want take a look at
With details, pseudo codes and C code.

Hope slavikn is still around and this answer helps...

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.