Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the insertion sort function definition given in chapter 16, page 1064. void insertionSort (int list[], int listLength) { int firstOutOfOrder, location; int temp; for

Consider the insertion sort function definition given in chapter 16, page 1064.

void insertionSort (int list[], int listLength) { int firstOutOfOrder, location; int 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 if } //end for-loop } //end insertionSort

1. Re-write this insertionSort function into a template function.

2. Assume statement double dList [50]; declares an array of 50 doubles, and dList is properly initialized. Write statement to call template function you defined in (a) to sort the array.

3. To use the template function defined in (a) to sort an array of class objects, the class must define (i.e., overload) what operator so the template function would work properly?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

=+Understand the different types of personal brands in social media

Answered: 1 week ago

Question

What is digital literacy? Why is it necessary?

Answered: 1 week ago