Search code examples
performancecomputational-geometryconvex-hull

Quickhull - all points on convex hull - bad performance


How to avoid bad performance in quickhull algorithm, when all points in input lie on convex hull?


Solution

  • QuickHull's performance comes mainly from being able to throw away a portion of the input with each recursive call (or iteration). This does not happen when all the points lie on a circle, unfortunately. Even in this case, it's still possible to obtain an O(nlog n) worst-case performance if the split step gives a fairly balanced partition at every recursive call. The ultimate worst-case which results in quadratic runtime is when we have grossly imbalanced splits (say one split always ends up empty) in each call. Because this pretty much depends on the dataset, there's not much one can do about it.

    You might want to try other algorithms instead, such as Andrew's variant of Graham's scan, or MergeHull. Both have guaranteed O(nlog n) worst-case time-complexity.