Graham Scan - Time Complexity

Time Complexity

Sorting the points has time complexity O(n log n). While it may seem that the time complexity of the loop is O(n2), because for each point it goes back to check if any of the previous points make a "right turn", it is actually O(n), because each point is considered at most twice in some sense. Each point can appear only once as a point in a "left turn" (because the algorithm advances to the next point after that), and as a point in a "right turn" (because the point is removed). The overall time complexity is therefore O(n log n), since the time to sort dominates the time to actually compute the convex hull.

Read more about this topic:  Graham Scan

Famous quotes containing the words time and/or complexity:

    If a man, notoriously and designedly, insults and affronts you, knock him down; but if he only injures you, your best revenge is to be extremely civil to him in your outward behaviour, though at the same time you counterwork him, and return him the compliment, perhaps with interest.
    Philip Dormer Stanhope, 4th Earl Chesterfield (1694–1773)

    It is not only their own need to mother that takes some women by surprise; there is also the shock of discovering the complexity of alternative child-care arrangements that have been made to sound so simple. Those for whom the intended solution is equal parenting have found that some parents are more equal than others.
    Elaine Heffner (20th century)