Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aaron-contreras/bubble-sort
A Ruby implementation of the bubble sort algorithm
https://github.com/aaron-contreras/bubble-sort
Last synced: 26 days ago
JSON representation
A Ruby implementation of the bubble sort algorithm
- Host: GitHub
- URL: https://github.com/aaron-contreras/bubble-sort
- Owner: aaron-contreras
- Created: 2020-05-19T11:56:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-19T12:14:22.000Z (over 4 years ago)
- Last Synced: 2024-11-12T03:44:11.524Z (about 2 months ago)
- Language: Ruby
- Size: 1000 Bytes
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bubble Sort
## Problem solving steps1. Will the program have a user interface?
- It will be a console application
2. Inputs?
- An array
3. Desired output?
- The sorted array
4. What needs to happen to go from the input to the desired output?
- Constraints
- Use the bubble sort methodology
- Bubble sort "bubbles" the largest element in an array to the end after each pass, so there's no need to check against it on the next pass, it will already be sorted.
- Algorithm
```
# Initialize a variable to determine if the array is sorted.
# Repeat until array is sorted.
Set the sorted variable to true.
# Loop through each element in the array.
# Compare the current element with the next element
# If the current element is greater than the next element
# Swap them
# Set the sorted variable to false
# After each pass through the array decrease the range of the array to loop through by 1.
# Return the sorted array
```