Lab10 - Thomas Nanke CIS 200-001 CIS 200L-001 Lab #10...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Thomas Nanke CIS 200-001 CIS 200L-001 Lab #10 Template Function for Selection, Insertion, and BubbleSort 4/4/08
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Machine type that I used is the PC with Microsoft XP Professional as the operating system. The compiler type is the Microsoft Visual 6.0 Compiler. The goal of this lab was to implement a template function for SelectionSort, InsertionSort, and BubbleSort, and then to test those implementations with three different arrays. The first array contained integers, the second float values, and the third char values. I wrote out each implementation for each sorting function before I started on my main(). After I completed that part and compiled without errors, I declared each array and made three copies of each so that I could be sure I was using an unsorted version of each array when I called each sorting function separately. Everything turned out like it should. Here is a copy of my source code (commented in the .cpp file) #include <iostream> using namespace std; template <class ItemType> class T { public: T(); int MinIndex(ItemType values[], int start, int end); void SelectionSort(ItemType values[], int numValues); void BubbleUp(ItemType values[], int start, int end); void BubbleSort(ItemType values[], int numValues); void InsertItem(ItemType values[], int start, int end); void InsertionSort(ItemType values[], int numValues); void Swap(ItemType& item1, ItemType& item2); void Print(ItemType A[]); private: ItemType values[10]; int numValues; }; template<class ItemType> T<ItemType>::T() { numValues = 0; } template<class ItemType> int T<ItemType>::MinIndex(ItemType values[], int start, int end) { int indexOfMin = start;
Background image of page 2
for(int index = start + 1; index <= end; index++) if(values[index] < values[indexOfMin])
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/25/2010 for the course CECS CIS 200 taught by Professor Jieshen during the Winter '08 term at University of Michigan-Dearborn.

Page1 / 8

Lab10 - Thomas Nanke CIS 200-001 CIS 200L-001 Lab #10...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online