To build two Bubble Sort algorithms. The first takes an array and returns a sorted array. The second sorts an array by accepting a block.
The algorithm considers all elements that are in their final, sorted position after one completed iteration. On the next iteration it sorts up to, but not including, elements already in their final position. This leads to about a 50% improvement in comparison count for worst-case efficiency of O(n^2).
- Clone into your local environment, OR
- Copy contents of file_name.rb, and run in Repl.it
Install Ruby
cd
into folder containing Ruby files- Run
ruby file_name.rb
- Bubble_Sort: Ascending Numeric or Alphabetic arrays
- Bubble_Sort_By: Ascending/Descending Numeric, Alphabetic or Word arrays.
- Ruby.
- Github, Git, Visual Studio Code.
- Repl.it
👤 Clifton Davies
- Github: @githubhandle
- Twitter: @twitterhandle
- Linkedin: linkedin
Contributions, issues and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!
- The Corgis!
This project is MIT licensed.