Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class elemType>
- void insertionSort(elemType list[], int length)
- {
- for (int firstOutOfOrder = 1; firstOutOfOrder < length;
- firstOutOfOrder++)
- if (list[firstOutOfOrder] < list[firstOutOfOrder - 1])
- {
- elemType temp = list[firstOutOfOrder];
- int location = firstOutOfOrder;
- do
- {
- list[location] = list[location - 1];
- location--;
- } while(location > 0 && list[location - 1] > temp);
- list[location] = temp;
- }
- } //end insertionSort
Advertisement
Add Comment
Please, Sign In to add comment