Skip to content

Comments

Added solution for bubblesort in javascript#1196

Merged
ghostmkg merged 1 commit intoghostmkg:mainfrom
Praneel-Shivarkar:feature-bubblesort
Oct 31, 2025
Merged

Added solution for bubblesort in javascript#1196
ghostmkg merged 1 commit intoghostmkg:mainfrom
Praneel-Shivarkar:feature-bubblesort

Conversation

@Praneel-Shivarkar
Copy link
Contributor

Bubble sort in JavaScript is a simple comparison-based algorithm that repeatedly scans the array, swaps adjacent out-of-order elements, and stops early if a full pass makes no swaps, ensuring the largest items “bubble” to the end each pass.
What it does
Compares neighboring pairs left-to-right and swaps if the left value is greater for ascending order.​

After each pass, the last unsorted position holds the maximum element, shrinking the inner loop range.​

An optimization tracks whether any swap occurred; if none, the array is already sorted and the algorithm terminates.

@ghostmkg ghostmkg merged commit 6e6f6da into ghostmkg:main Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants