GATE | GATE CS Mock 2018 | Question 8

The expression [ (x + y) + |x – y| ] / 2 is equal to __________ .

(A) the maximum of x and y
(B) the minimum of x and y
(C) 1
(D) none of the above


Answer: (A)

Explanation: As we know that, if x > y, then |x – y| = x – y and
if x < y then |x – y| = y – x , because value of |x – y| is always non-negative. Therefore, Case 1: If x > y :
(x + y) + |x – y| ] / 2
= (x + y) + (x – y) ] / 2
= 2x / 2
= x (Maximum of x , y)

Case 2: If x < y : (x + y) + |x – y| ] / 2 = (x + y) + (y – x) ] / 2 = 2y / 2 = y (Maximum of x , y) Therefore, in both the cases we get maximum of (x, y). So, option (A) is correct. Note that you can take some random values of x and y and verify given options.

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


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