I know the complexity is O(nlog(n)). But why? How do you come to this answer?
Any help would be much appreciated, I’m very interested to know!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Its average case complexity is considered to be
O(n log(n)), whereas in the worst case it takesO(n^2)(quadratic).Consider the following pseudo-code:
The partition is determined by the line passing through two distinct extreme points: the rightmost lowest
rand the leftmost highest pointsl. Finding the extremes requireO(n)time.For the recursive function, it takes
nsteps to determine the extreme pointz, but the cost of recursive calls depends on the sizes of setAand setB.Best case. Consider the best possible case, when each partition is almost balanced. Then we have
T(n) = 2 T(n/2) + O(n).This is a familiar recurrence relation, whose solution is
T(n) = O(n log(n)).This would occur with randomly distributed points.
Worst case. The worst case occurs when each partition is an extremely unbalanced. In that case the recurrence relation is
Repeated expansion shows this is
O(n^2). Therefore, in the worst case the QuickHull is quadratic.http://www.personal.kent.edu/~rmuhamma/Compgeometry/MyCG/ConvexHull/quickHull.htm