Laboratory 9 Solutions
Solution to bubble_sort code:
/******************************************************************* * Name: Brenda Student * Date: 4/19/14 * Course: CSCI 132 Section 01 * Assignment: Lab 9 * Instructor: Royden * Function: bubble_sort() * Purpose: Sort a list using bubble-sort algorithm ***************************************************************************/ template <class Record> void Sortable_list<Record>::bubble_sort() { for (int i = count; i > 0; i -- ) { for (int j = 0; j < i - 1; j++) { if( entry[j] > entry[j+1]) { swap(j, j+ 1); } } } }
Home | | Syllabus | | Assignments | | Lecture Notes