Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb0ccec9

Browse files
Update bubble sort (TheAlgorithms#2806)
1 parent9567a78 commitb0ccec9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎Sorts/BubbleSort.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class BubbleSort implements SortAlgorithm {
1818
*/
1919
@Override
2020
public <TextendsComparable<T>>T[]sort(T[]array) {
21-
for (inti =0,size =array.length;i <size -1; ++i) {
21+
for (inti =1,size =array.length;i <size; ++i) {
2222
booleanswapped =false;
23-
for (intj =0;j <size -1 -i; ++j) {
23+
for (intj =0;j <size -i; ++j) {
2424
if (greater(array[j],array[j +1])) {
2525
swap(array,j,j +1);
2626
swapped =true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp