Uploaded by jisameje

bubble-sort

advertisement
bubble sort (latex)
simon el hadidi
29. january 2024
1
introduction
okay in short i am experimenting around whether i like this, markdown, plaintext code comments, html, or my own language without further ado, these are
my notes on bubble sort
2
bubble sort
• time complexity: o(n2 )
• space complexity: o(1)
• comparison sort
• stable sort
• in-place
2.1
uses
• orders elements
• sorting small list of items
• educational
• bad example
2.2
advantages
• fast to implement
• simple to implement
• easy to visualise
1
2.3
disadvantages
• inefficient
• slow
• instructions are wasted
2.4
process
1. start at the first item in the list
2. compare with the next item
3. if larger swap
4. continue with every subsequent item
5. repeat for every other item
6. if no swaps done stop
2.5
optimisations
• insertion sort (smaller factor)
• cocktail shaker sort (bubble sort in both directions)
3
conclusion
i can probably do better than this but this is already a little bit show-off-y i like
latex but unless i have a reason to use it i will probably keep my distance solid
8/10. it does its job well, i just lack skill
2
Download