+ 1

Write a program to sort an array of elements

C program

22nd Dec 2021, 2:18 AM
Monalisa
Monalisa - avatar
17 ответов
+ 3
https://code.sololearn.com/crTy7xEBbZwQ/?ref=app
22nd Dec 2021, 6:55 AM
Mafdi
Mafdi - avatar
22nd Dec 2021, 3:11 AM
Monalisa
Monalisa - avatar
+ 2
Check it
22nd Dec 2021, 3:12 AM
Monalisa
Monalisa - avatar
+ 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
22nd Dec 2021, 4:09 AM
Shira
Shira - avatar
+ 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.
22nd Dec 2021, 6:13 AM
A͢J
A͢J - avatar
+ 1
You can use any sorting algorithm like selection sort ..bubble sort you can search on Google u can easily find
22nd Dec 2021, 3:04 AM
Shira
Shira - avatar
+ 1
I search it already but when I run this program show error
22nd Dec 2021, 3:06 AM
Monalisa
Monalisa - avatar
22nd Dec 2021, 3:08 AM
Shira
Shira - avatar
+ 1
Tq
22nd Dec 2021, 8:03 AM
Monalisa
Monalisa - avatar
+ 1
Tq
24th Dec 2021, 6:34 AM
Monalisa
Monalisa - avatar
0
Answer please
22nd Dec 2021, 2:18 AM
Monalisa
Monalisa - avatar
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; }
23rd Dec 2021, 3:41 PM
Shafiq Almatari
Shafiq Almatari - avatar
23rd Dec 2021, 6:06 PM
Nana Senne Ackaah Gyasi
Nana Senne Ackaah Gyasi - avatar
0
I hope my Python code helps
23rd Dec 2021, 6:06 PM
Nana Senne Ackaah Gyasi
Nana Senne Ackaah Gyasi - avatar
0
Do this problem by using hashing
23rd Dec 2021, 8:18 PM
Govind Singh
Govind Singh - avatar
- 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);
23rd Dec 2021, 3:04 PM
Aditya Rathod