Question 11094 – Programming
January 16, 2024
Data-Link-Layer
January 16, 2024
Question 11094 – Programming
January 16, 2024
Data-Link-Layer
January 16, 2024

Question 11095 – Programming

Let a and b be two sorted arrays containing n integers each, in non-decreasing order. Let c be a sorted array containing 2n integers obtained by merging the two arrays a and b. Assuming the arrays are indexed starting from 0, consider the following four statements

1. a[i] ≥ b [i] => c[2i] ≥ a [i]
2. a[i] ≥ b [i] => c[2i] ≥ b [i]
3. a[i] ≥ b [i] => c[2i] ≤ a [i]
4. a[i] ≥ b [i] => c[2i] ≤ b [i] 

Which of the following is TRUE?

Correct Answer: C

Question 5 Explanation: 
a[i] ≥ b[i]
Since both ‘a’ and ‘b’ are sorted in the beginning, there are ‘i’ elements than or equal to a[i] and similarly ‘i’ elements smaller than or equal to b[i]. So, a[i] ≥ b[i] means there are 2i elements smaller than or equal to a[i] and hence in the merged array, a[i] will come after these 2i elements. So, c[2i] ≤ a[i].
Similarly, a[i] ≥ b[i] says for b that, there are not more than 2i elements smaller than b[i] in the sorted array. So, b[i] ≤ c[2i].
So, option (C) is correct.
A
only I and II
B
only I and IV
C
only II and III
D
only III and IV
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!