lab10 - #include <iostream> # using...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: #include <iostream> # using namespace std; u template <class ItemType> class T { public: T(); int MinIndex(ItemType values, int start, int end); //Post: Function value = index of the smallest value in values[start]...values[end] void SelectionSort(ItemType values, int numValues); //Post: Sorts array values[0...numValues-1] into ascending order by key void BubbleUp(ItemType values, int start, int end); //Post: Neighboring elements that were out of order have been swapped between //values[start] and values[end], beginning at values[end]. void BubbleSort(ItemType values, int numValues); //Post: Sorts array values[0...numValues-1] into ascending order by key void InsertItem(ItemType values, int start, int end); //Post: Elements between values[start] and values[end] have been sorted //ascending order by key void InsertionSort(ItemType values, int numValues); //Post: Sorts array values[0...numValues-1] into ascending order by key void Swap(ItemType& item1, ItemType& item2); //Post: Swaps the values of item1 and item2 void Print(ItemType A); //Post: Takes an array as an input parameter and prints out the values private: ItemType values[10]; //declaration of the values array int numValues; //variable that will represent the number of values //in the array }; } template<class ItemType> T<ItemType>::T() //class constructor { numValues = 0; } template<class ItemType> int T<ItemType>::MinIndex(ItemType values, int start, int end) //Implementation of the MinIndex function. Takes the values array, //starting location, and ending location of the array as input { int indexOfMin = start; for(int index = start + 1; index <= end; index++) if(values[index] < values[indexOfMin]) indexOfMin = index; i return indexOfMin; } template<class ItemType> void T<ItemType>::SelectionSort(ItemType values, int numValues) //Implementation of the SelectionSort function. Tales the values array //and the number of values in the array as input....
View Full Document

Page1 / 5

lab10 - #include <iostream> # using...

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

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