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
Smoothsort
(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!
==Analysis== Smoothsort takes {{math|''O''(''n'')}} time to process a presorted array, {{math|''O''(''n'' log ''n'')}} in the worst case, and achieves nearly linear performance on many nearly sorted inputs. However, it does not handle all nearly sorted sequences optimally. Using the count of inversions as a measure of un-sortedness (the number of pairs of indices {{mvar|i}} and {{mvar|j}} with {{math|''i'' < ''j''}} and {{math|''A''[''i''] > ''A''[''j'']}}; for randomly sorted input this is approximately {{math|''n''<sup>2</sup>/4}}), there are possible input sequences with {{math|''O''(''n'' log ''n'')}} inversions which cause it to take {{math|Ξ©(''n'' log ''n'')}} time, whereas other [[adaptive sort|adaptive sorting]] algorithms can solve these cases in {{math|''O''(''n'' log log ''n'')}} time.<ref name="hertel">{{cite journal |last=Hertel |first=Stefan |title=Smoothsort's behavior on presorted sequences |journal=[[Information Processing Letters]] |volume=16 |issue=4 |date=13 May 1983 |pages=165β170 |url=http://scidok.sulb.uni-saarland.de/volltexte/2011/4062/pdf/fb14_1982_11.pdf |archive-url=https://web.archive.org/web/20151208051150/http://scidok.sulb.uni-saarland.de/volltexte/2011/4062/pdf/fb14_1982_11.pdf |archive-date=2015-12-08 |url-status=live |doi=10.1016/0020-0190(83)90116-3 }}</ref> The smoothsort algorithm needs to be able to hold in memory the sizes of all of the trees in the Leonardo heap. Since they are sorted by order and all orders are distinct, this is usually done using a [[bit vector]] indicating which orders are present. Moreover, since the largest order is at most {{math|''O''(log ''n'')}}, these bits can be encoded in {{math|''O''(1)}} machine words, assuming a [[transdichotomous machine model]]. Note that {{math|''O''(1)}} machine words is not the same thing as ''one'' machine word. A 32-bit vector would only suffice for sizes less than {{math|1=''L''(32) = 7049155}}. A 64-bit vector will do for sizes less than {{math|1=''L''(64) = 34335360355129 β 2<sup>45</sup>}}. In general, it takes {{math|1/log<sub>2</sub>(''[[Golden ratio|Ο]]'') β 1.44}} bits of vector per bit of size.
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)