Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,17 @@ void swap(int& a, int& b) {
void bubble_sort_descending(int* array, unsigned int size) {
for (unsigned int i = 0; i < size - 1; i++)
{
//#######################################################
for (unsigned int j=0; j<size-1-i;j++){
//#######################################################
//Implement here
;

if (array[j] > array[j+1]){
double k=0;
k=array[j];
array[j]=array[j+1];
array[j+1]=k
}

//#######################################################
}
}
Expand All @@ -152,7 +160,17 @@ void insertion_sort_descending(int* array, unsigned int size) {
{
//#######################################################
//Implement here
;
int temp=array[i];
int j=i-1;
while(1){
if (j<0) break;
if(array[j]<=temp) break;
array[j+1]=array[j];
j--

}
array[j+1]=temp

//#######################################################
}
}
Expand All @@ -162,7 +180,18 @@ void selection_sort_descending(int* array, unsigned int size) {
{
//#######################################################
//Implement here
;
int min=array[i];
int min_idx = i;
for (unsigned int j = i+1; j<size; j++){
if (array[j]<min){
min=array[j];
min_idx=j;
}


}
swap(array[i], array[min_idx]);

//#######################################################
}
}
Expand Down