Best case of bubble sort [O(n)] would be linear given the array is already sorted and we only need to go through the items a single time. Far from the average case, but considering that wikipedia, the bigocheatsheet, and other notable references all include the "best case" sort of bubble sort as O(n) I added it in here as well.
The callback method was actually there for an experiment I did. It was an easy way for me to output something to the console for every operation executed utilizing bubble sort. I actually meant to remove that during this post (I copied the code snippet directly from my referenced github repo) so thanks for pointing that out so I can remove it.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Best case of bubble sort [O(n)] would be linear given the array is already sorted and we only need to go through the items a single time. Far from the average case, but considering that wikipedia, the bigocheatsheet, and other notable references all include the "best case" sort of bubble sort as O(n) I added it in here as well.
bigocheatsheet.com/
en.wikipedia.org/wiki/Bubble_sort
The average and worst cases are both n^2.
The callback method was actually there for an experiment I did. It was an easy way for me to output something to the console for every operation executed utilizing bubble sort. I actually meant to remove that during this post (I copied the code snippet directly from my referenced github repo) so thanks for pointing that out so I can remove it.