Question: template void insertionSort(T list[], int listLength) { int firstOutOfOrder, location; T temp; for (firstOutOfOrder = 1; firstOutOfOrder < listLength; firstOutOfOrder++) { if (list[firstOutOfOrder] < list[firstOutOfOrder

template

void insertionSort(T list[], int listLength)

{

int firstOutOfOrder, location;

T temp;

for (firstOutOfOrder = 1; firstOutOfOrder < listLength; firstOutOfOrder++)

{

if (list[firstOutOfOrder] < list[firstOutOfOrder - 1])

{

temp = list[firstOutOfOrder];

location = firstOutOfOrder;

do {

list[location] = list[location - 1];

location--;

} while (location > 0 && list[location - 1] > temp);

list[location] = temp;

} // end of if statement

} // end of for-loop

} // end of insertionSort template

When given the what is above... [PLEASE ANSWER FULLY]

a) Assume dList[50] declares an array of 50 doubles, and is properly initialized. Write a statement to call template function defined above to sort the array.

b) To use the template function defined above to sort an array of class objects, the class must overload what operator so the template function can work properly?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!