Question: write in c programming language #6.11 6.11 (Bubble Sort) The bubble sort presented in Fig. 6.15 is inefficient for large arrays. Make the following simple

write in c programming language #6.11
write in c programming language #6.11 6.11 (Bubble Sort) The bubble sort
presented in Fig. 6.15 is inefficient for large arrays. Make the following

6.11 (Bubble Sort) The bubble sort presented in Fig. 6.15 is inefficient for large arrays. Make the following simple modifications to improve its performance. a) After the first pass, the largest number is guaranteed to be in the highest-numbered el- ement of the array; after the second pass, the two highest numbers are "in place," and so on. Instead of making nine comparisons on every pass, modify the bubble sort to make eight comparisons on the second pass, seven on the third pass and so on. b) The data in the array may already be in the proper or near-proper order, so why make nine passes if fewer will suffice? Modify the sort to check at the end of each pass whether any swaps have been made. If none has been made, then the data must already be in the proper order, so the program should terminate. If swaps have been made, then at least one more pass is needed. J: 6.8 Sorting Arrays 235 torreasing order or if the values are ideal e he values as they are. If a pairs to decreasing order, their values are swapped in the array, // Fig. 6.15: fig06 15. Sorting an array's values into ascending order. include #define SIZE 10 // function main begins program execution 7 int main(void) // initialize a int a[SIZE] = {2, 6, 4, 8, 10, 12, 89, 68, 45, 37); 10 puts("Data items in original order): // output original array for (size_t i = 0; i a[i+1]) { int hold = a[i]; a[i] = a[i + 1]: ai + 1] - hold; Soba 36 puts(" Data items in ascending order"); 39 // output sorted array for (size_t i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!