Question: Data Structures using C++ Consider the definition the following function template: template Type func(Type list[], int size) { Type x = list[0]; Type y =

Data Structures using C++

Consider the definition the following function template:

template

Type func(Type list[], int size)

{

Type x = list[0];

Type y = list[size - 1];

for (int j = 1; j < size / 2; j++)

{

if (x < list[j])

x = list[j];

if (y > list[size - 1 - j])

y = list[size - 1 - j];

}

return x + y;

}

Further suppose that you have the following declarations

int list[10] = {4,2,10,18,14,19,25,13,21,35};

string strList[] = {"One", "Three", "Six", "Five", "Two", "Four"};

What is the expected output of the following statement?

cout << func(list, 10) << endl;

What is the expected output of the following statements?

cout << func(strList, 6) << endl;

(Trying to understand as I had a similar question and got it wrong. I executed this one the same way and got 31 for (a) and TwoOne for (b), but I'm not sure it's right because I executed a similar question the same way and got it wrong.)

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!