+ 1
Write a program to sort an array of elements
C program
20 Respostas
+ 3
https://code.sololearn.com/crTy7xEBbZwQ/?ref=app
+ 2
Check it
+ 2
Monalisa Rout
This is wrong
if(i > j);
a=i;
i=j;
j=a;
Semicolon is used to break statement so here scope of if block is till itself only.
Other 3 statements are outside the if block.
+ 1
I search it already but when I run this program show error
+ 1
Tq
+ 1
Tq
0
Answer please
0
You can use this function to sort array element using shell algorithm
int shellSort(int arr[], int N) {
for (int gap = N/2; gap > 0; gap /= 2)
{
for (int i = gap; i < N; i += 1)
{
//sort sub lists created by applying gap
int temp = arr[i];
int j=i;
while( j >= gap && arr[j - gap] >temp; j -= gap) arr[j] = arr[j - gap];
arr[j] = temp;
}
}
return 0;
}
0
I hope my Python code helps
0
Do this problem by using hashing
- 2
// function prototype
void swap(int *a, int *b);
void selection_sort(int *arr, int len);
int main() {
// length of unsorted array
int len;
printf("Enter array length: ");
scanf("%d", &len);