CS 54 - Lab 8


Lab Assignment

Today we will learn about one of the more interesting problems in programming: sorting. There are many sorting algorithms available, each with its own merits and disadvantages. The first algorithm we will see is called bubble sort, so named because the smaller items “bubble” to the front of the array.


Lab Assignment - Part I (Required - 8 Points)

Implement a function that, given an array an array of size integers, will sort the array using the bubble sort algorithm:
void bubbleSort(int inputArray[], int size);
In your main(), create an array of 30 random integers and sort them using the bubbleSort() function.


Lab Assignment - Part II (Required - 10 Points)

Write a function called void printArray(int inputArray[], int size); that will print an array with size number of integers.


Lab Assignment - Part III (Extra Credit - 12 Points)

Choose one of the following for extra credit:

Each option is worth 2 points. Choose one and only one to qualify for Part III. Doing more than one option will not let you attain more than two extra points (i.e., doing two options is not worth four points).


Grading & Submission


[Dilbert]