• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | GATE-CS-2006 | Question 53

Consider the following C-function in which a[n] and b[m] are two sorted integer arrays and c[n + m] be another integer array. 

C
void xyz(int a[], int b [], int c[])
{
  int i, j, k;
  i = j = k = O;
  while ((i<n) && (j<m))
     if (a[i] < b[j]) c[k++] = a[i++];
     else c[k++] = b[j++];
}

Which of the following condition(s) hold(s) after the termination of the while loop? (GATE CS 2006) (i) j < m, k = n+j-1, and a[n-1] < b[j] if i = n (ii) i < n, k = m+i-1, and b[m-1] <= a[i] if j = m

(A)

only (i)

(B)

only (ii)

(C)

either (i) or (ii) but not both

(D)

neither (i) nor (ii)

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