• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | GATE-CS-2014-(Set-1) | Question 50

Consider the following C function in which size is the number of elements in the array E: The value returned by the function MyX is the C
int MyX(int *E, unsigned int size)
{
    int Y = 0;
    int Z;
    int i, j, k;
    for(i = 0; i < size; i++)
        Y = Y + E[i];
    for(i = 0; i < size; i++)
        for(j = i; j < size; j++)
        {
            Z = 0;
            for(k = i; k <= j; k++)
                Z = Z + E[k];
            if (Z > Y)
                Y = Z;
        }
    return Y;
}

(A)

maximum possible sum of elements in any sub-array of array E.

(B)

maximum element in any sub-array of array E.

(C)

sum of the maximum elements in all possible sub-arrays of array E

(D)

the sum of all the elements in the array E.

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments