Search code examples
algorithmcomputational-geometrycgalconvex-hullgrahams-scan

Input for Jarvis algorithm so that is faster than Graham's (convex hull)


Jarvis: This algorithm requires O(nh) time in the worst case for n input points with h extreme points.

Graham: O(nlogn) in the worst case scenario.

Source the ref of CGAL, from where I use the two algorithms.

That means that Jarvis can be faster for a dataset (let's say in 2 dimensions), when h is less than logn. However I would like to see it in action, but I fail in finding a dataset for this purpose. Does anybody know?

Googling yield this link, which actually supports what I am claiming above.


Solution

  • Let's assume that we have a big traingle and a lot of points inside it. The number of points on the hull(that is, h) is 3. If the number of points inside is really big, then h = 3 is less than log n. Jarvis would be much faster here.