Skip to content

Commit 9961df7

Browse files
committed
Added comment in bubble sort algorithm
1 parent e5f3fcb commit 9961df7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sorting/bubble_sort.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//bubble sort elements
12
# include <iostream>
23
using namespace std;
34

@@ -9,15 +10,15 @@ int main()
910
int arr[n];
1011
cout<<"Enter the elements of array"<<endl;
1112
for (int i = 0; i < n; i++)
12-
{
13+
{ //array elements input
1314
cin>>arr[i];
1415
}
1516
for (int i = 0; i < n; i++)
1617
{
1718
for (int j= 0; j< n-1; j++)
18-
{
19+
{ //comparing adjecent elements of array
1920
if (arr[j]>arr[j+1])
20-
{
21+
{ // swaping array elements
2122
temp = arr[j];
2223
arr[j] = arr[j+1];
2324
arr[j+1] = temp;

0 commit comments

Comments
 (0)