Skip to content

Commit bba6735

Browse files
Merge pull request #19 from Shubhk15/patch-1
Changes in for loop for sorting
2 parents 2ae6cc2 + fc9e3f6 commit bba6735

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Bubble Sort.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ public static void main(String[] args)
1515
}
1616

1717
//Sorting
18-
for(int i=0; i<6; i++)
18+
for(int i=0; i<5; i++)
1919
{
20-
for(int j=0; j<5; j++)
20+
for(int j=i+1; j<6; j++)
2121
{
22-
if(array[j]>array[j+1])
22+
if(array[j]>array[i])
2323
{
2424
int temp=array[j];
25-
array[j]=array[j+1];
26-
array[j+1]=temp;
25+
array[j]=array[i];
26+
array[i]=temp;
2727
}
2828
}
2929
}
@@ -35,4 +35,4 @@ public static void main(String[] args)
3535
}
3636

3737
}
38-
}
38+
}

0 commit comments

Comments
 (0)