Skip to content

cliftondavies/Bubble-Sort

Repository files navigation

Bubble-Sort

Aim

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.

screenshot

Implementation

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).

Getting Started

  • Clone into your local environment, OR
  • Copy contents of file_name.rb, and run in Repl.it

Prerequisites

Install Ruby

Usage (local environment)

  1. cd into folder containing Ruby files
  2. Run ruby file_name.rb

Run Tests

  • Bubble_Sort: Ascending Numeric or Alphabetic arrays
  • Bubble_Sort_By: Ascending/Descending Numeric, Alphabetic or Word arrays.

Tools & Technologies Used

  • Ruby.
  • Github, Git, Visual Studio Code.
  • Repl.it

Authors

👤 Clifton Davies

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a ⭐️ if you like this project!

Acknowledgments

  • The Corgis!

📝 License

This project is MIT licensed.

About

An optimised Bubble Sort algorithm.

Topics

Resources

License

Stars

Watchers

Forks

Languages