Question 11090 – Programming
January 16, 2024
Question 11095 – Programming
January 16, 2024
Question 11090 – Programming
January 16, 2024
Question 11095 – Programming
January 16, 2024

Question 11094 – Programming

Let a be an array containing n integers in increasing order. The following algorithm determines whether there are two distinct numbers in the array whose difference is a specified number S > 0.

i = 0;
j = 1;
while (j < n )
{
    if (E) j++;
    else if (a[j] - a[i] == S) break;
    else i++;
}
if (j < n)
    printf("yes")
else
   printf ("no"); 

Choose the correct expression for E.

Correct Answer: B

Question 4 Explanation: 
For some ‘i’ if we find that difference of (A[j] – A[i] < S) we increment ‘j’ to make this difference wider so that it becomes equal to S.
If at times difference becomes greater than S we know that it won’t reduce further for same ‘i’ and so we increment the ‘i’.
A
a[j] – a[i] > S
B
a[j] – a[i] < S
C
a[i] – a[j] < S
D
a[i] – a[j] > S
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!!