Skip to content

Commit f4fc74c

Browse files
committed
Debug
1 parent 9fedd43 commit f4fc74c

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

Sorting/Bubble_sort.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const int dir8[2][8] = {{-1,-1,-1,0,1,1,1,0},{-1,0,1,1,-1,0,1,-1}};
1818
const int N = 10010;
1919
int a[N];
2020
void bubbleSort(int n){
21-
bool swapped = false;
22-
while(!swapped){
21+
bool swapped = true;
22+
while(swapped){
2323
swapped = false;
2424
for(int i=1;i<n;i++)
2525
if(a[i] > a[i+1])

Sorting/Selection_sort.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const int dir8[2][8] = {{-1,-1,-1,0,1,1,1,0},{-1,0,1,1,-1,0,1,-1}};
1818
const int N = 10010;
1919
int a[N];
2020
void selectionSort(int n){
21-
int idx = 1;
2221
for(int i=1;i<=n;i++){
23-
for(int j=1;j<=n;j++)
22+
int idx=i;
23+
for(int j=i;j<=n;j++)
2424
if(a[j] < a[idx])
2525
idx = j;
2626
swap(a[i],a[idx]);

0 commit comments

Comments
 (0)