Bubble Sort
Published in
2 min readApr 1, 2021
Bubble Sort:
var unOrderArray = [5,2,13,7,11,3]
Suppose we have array of unordered numbers(In this case Prime number, subset of natural numbers)
We have two option to sort this.
1. Ascending order.
2. Descending order.
But what if all elements are sorted itself.
ex: var sortedArray = [2, 3, 5, 7, 11, 13]
It will sort all sorted elements 😂.
This case can be handled by assuming all element are sorted and if it holds true than we will break the loop.✌🏼
Supporting code:
Thanks for reading.
Please let me know if you have any queries or doubt.
roshankumar350@gmail.com
Roshan kumar Sah.