Question: For this task, you will refresh array access by implementing the simplest sorting algorithm you have learned from your Java programming: bubble sorting. assign2/task5 contains

For this task, you will refresh array access by implementing the simplest sorting algorithm you have learned from your Java programming: bubble sorting. assign2/task5 contains the source code array.c and test code array_test.c. Please implement the bubbleSort function inside array.c, and compile array.c and array_test.c into an executable. array_test.c contains a few simple tests against your bubbleSort. Please make sure your code passes all tests.

array.c

#include

/* function prototypes: */

void printArray(int a[], int size);

void bubbleSort(int a[], int size);

/* prints out the contents of an array

* a: the array of int values

* size: the number of elements in the array

*/

void printArray(int a[], int size) {

// An example of a function that doesn't return a value.

int i;

printf(\"Array Contents: \");

for (i = 0; i

printf(\"%d \", a[i]);

}

printf(\" \");

}

/* review bubble sorting from your java class and implement

* it for a C array, in which elements could be accessed through

* index notation just like Java arrays.

* Precondition:

* a: the array of int values

* size: the number of elements in the array

* returns: nothing

* Postcondition:

* a is sorted in ascending order

*/

void bubbleSort(int a[], int size) {

//TODO: write this function

}

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 Programming Questions!