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
Cocktail shaker sort
(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!
{{Short description|Sorting algorithm}} {{Infobox Algorithm |class=[[Sorting algorithm]] |image=[[File:Sorting shaker sort anim.gif|Visualization of shaker sort]] |data=[[Array data structure|Array]] |best-time= <math>O(n)\,</math> |average-time= <math>O(n^2)\,</math> |time=<math>O(n^2)\,</math> |space=<math>O(1)</math> |optimal=No }} '''Cocktail shaker sort''',<ref name="Knuth">{{cite book|title=Art of Computer Programming|edition=1st|pages=110–111|last=Knuth|first=Donald E.|author-link=Donald Knuth|volume=3. Sorting and Searching|chapter=Sorting by Exchanging|publisher=[[Addison-Wesley]]|date=1973|isbn=0-201-03803-X}}</ref> also known as '''bidirectional bubble sort''',<ref>{{cite book|first1=Paul E.|last1=Black|first2=Bob|last2=Bockholt|url=http://xlinux.nist.gov/dads/HTML/bidirectionalBubbleSort.html|chapter=bidirectional bubble sort|title=Dictionary of Algorithms and Data Structures|editor1-first=Paul E.|editor1-last=Black|publisher=[[National Institute of Standards and Technology]]|date=24 August 2009|access-date=5 February 2010|archive-url=https://web.archive.org/web/20130316180005/http://xlinux.nist.gov/dads//HTML/bidirectionalBubbleSort.html|archive-date=16 March 2013|url-status=dead}}</ref> '''cocktail sort''', '''shaker sort''' (which can also refer to a variant of [[selection sort]]), '''ripple sort''', '''shuffle sort''',<ref name="Duhl1986">{{cite book|first=Martin|last=Duhl|contribution=Die schrittweise Entwicklung und Beschreibung einer Shuffle-Sort-Array Schaltung|title=HYPERKARL aus der Algorithmischen Darstellung des BUBBLE-SORT-ALGORITHMUS|language=de|journal=Projektarbeit|year=1986|publisher=Technical University of Kaiserslautern}}</ref> or '''shuttle sort''', is an extension of [[bubble sort]]. The algorithm extends bubble sort by operating in two directions. While it improves on bubble sort by more [[Bubble sort#Rabbits and turtles|quickly moving items to the beginning of the list]], it provides only marginal performance improvements. Like most variants of bubble sort, cocktail shaker sort is used primarily as an educational tool. More efficient algorithms such as [[quicksort]], [[merge sort]], or [[timsort]] are used by the sorting libraries built into popular programming languages such as Python and Java.<ref>{{Cite web|url=https://bugs.openjdk.java.net/browse/JDK-6804124|title=[JDK-6804124] (coll) Replace "modified mergesort" in java.util.Arrays.sort with timsort - Java Bug System|website=bugs.openjdk.java.net|access-date=2020-01-11}}</ref><ref>{{Cite web|url=https://mail.python.org/pipermail/python-dev/2002-July/026837.html|title=[Python-Dev] Sorting|last=Peters|first=Tim|date=2002-07-20|access-date=2020-01-11}}</ref>
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)