{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This preview shows pages 1–3. 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
Image of page 1

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

View Full Document Right 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;
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern