Skip to content

Commit

Permalink
Merge branch 'master' into bug_in_ncr_modulo_p_patch
Browse files Browse the repository at this point in the history
  • Loading branch information
vil02 committed Aug 30, 2024
2 parents 3e0fb86 + 519d37f commit 756c9cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sorting/counting_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ int *Counting_Sort(int Arr[], int N) {
int *Sorted_Arr = new int[N];

int *Count = new int[max - min + 1];
for (int i = 0; i < max - min + 1; ++i) {
Count[i] = 0;
}

for (int i = 0; i < N; i++) Count[Arr[i] - min]++;

Expand All @@ -37,6 +40,7 @@ int *Counting_Sort(int Arr[], int N) {
Count[Arr[i] - min]--;
}

delete[] Count;
return Sorted_Arr;
}

Expand All @@ -51,6 +55,7 @@ int main() {
Sorted_Arr = Counting_Sort(Arr, N);
cout << "\n\t Sorted Array = ";
Print(Sorted_Arr, N);
delete[] Sorted_Arr;
cout << endl;

return 0;
Expand Down
5 changes: 5 additions & 0 deletions sorting/library_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ void librarySort(int *index, int n) {
index_pos_for_output++;
}
}
delete[] numbered;
delete[] gaps;
for (int i = 0; i < 2; ++i) {
delete[] library[i];
}
}

int main() {
Expand Down

0 comments on commit 756c9cf

Please sign in to comment.