Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Graham scan
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Time complexity == {{uncited-section|date=February 2024}} Sorting the points has time complexity O(''n'' log ''n''). While it may seem that the time complexity of the loop is O(''n''<sup>2</sup>), 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 <math>(x_2,y_2)</math> in a "left turn" (because the algorithm advances to the next point <math>(x_3,y_3)</math> after that), and as a point <math>(x_2,y_2)</math> in a "right turn" (because the point <math>(x_2,y_2)</math> 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.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)