Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class T>
- void ArrayClass<T>::insertionSort(int insertindex) //x to be passed in as 0
- {
- if (insertindex == usersize - 1 || insertindex == -1) //account of off by one error when reaching the maximum size;
- {
- return;
- }
- else
- {
- int i = insertindex; //i is used to keep of the element that is being compared with every value prior to it 'j';
- int j = i;
- if (myarr[j] < myarr[i + 1])
- {
- swapPosition(j, i + 1);
- showArray();
- i--;
- insertionSort(i);
- }
- //showArray();
- insertionSort(insertindex + 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement