Skip to content

fix: update bubble sort outer loop to run n-1 times#1549

Open
SenithVijayantha wants to merge 1 commit intokunal-kushwaha:mainfrom
SenithVijayantha:bubbleSort-bug-fix
Open

fix: update bubble sort outer loop to run n-1 times#1549
SenithVijayantha wants to merge 1 commit intokunal-kushwaha:mainfrom
SenithVijayantha:bubbleSort-bug-fix

Conversation

@SenithVijayantha
Copy link

Description:

  • Updated the outer loop condition in the bubble method from i < arr.length to i < arr.length - 1.
  • This ensures the loop runs exactly n-1 times, eliminating the unnecessary final pass.

change outer loop condition in bubble sort from i < arr.length to i < arr.length - 1 to avoid unnecessary last pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant