# C | Arrays | Question 5

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.

 `void` `xyz(``int` `a[], ``int` `b [], ``int` `c[]) ` `{ ` `  ``int` `i, j, k; ` `  ``i = j = k = O; ` `  ``while` `((i

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)

Explanation: The function xyz() is similar to merge() of mergeSort().

The condition (i) is true if the last inserted element in c[] is from a[] and condition (ii) is true if the last inserted element is from b[].

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :

6

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.