+ 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
Inside for loop u need to write to do swappings with array not i and j if u will assign value of i and i then u can't do sorting
+ 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
You can use any sorting algorithm like selection sort ..bubble sort you can search on Google u can easily find
+ 1
I search it already but when I run this program show error
+ 1
Monalisa Rout if you will copy code from genuine site then it will give u stray errors so better to write it self.
Take as a reference
https://code.sololearn.com/cbRFLNuYvPsV/?ref=app
https://code.sololearn.com/c88I98k87cQm/?ref=app
https://code.sololearn.com/WxkeviJgJYV8/?ref=app
https://code.sololearn.com/cbMK1wW7pTd9/?ref=app
+ 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);