Question

If p,q,r,sp, q, r, s are distinct integers such that:

f(p,q,r,s)=max⁡(p,q,r,s)f(p, q, r, s) = \max(p, q, r, s)
g(p,q,r,s)=min⁡(p,q,r,s)g(p, q, r, s) = \min(p, q, r, s)
h(p,q,r,s)=remainder of (p×q)/(r×s) if (p×q)>(r×s) or remainder of (r×s)/(p×q) if (r×s)>(p×q)h(p, q, r, s) = \text{remainder of } (p \times q) / (r \times s) \text{ if } (p \times q) > (r \times s) \text{ or remainder of } (r \times s) / (p \times q) \text{ if } (r \times s) > (p \times q)

Also a function fgh(p,q,r,s)=f(p,q,r,s)×g(p,q,r,s)×h(p,q,r,s)fgh(p, q, r, s) = f(p, q, r, s) \times g(p, q, r, s) \times h(p, q, r, s).
Also the same operations are valid with two variable functions of the form f(p,q)f(p, q).
What is the value of fg(h(2,5,7,3),4,6,8)fg(h(2, 5, 7, 3), 4, 6, 8)?

Official answer and solution
Official answer
8
From
Official GATE 2015 answer key

Solution

Evaluate the innermost custom operation h(2,5,7,3)h(2, 5, 7, 3) first, then evaluate the composite function fgfg.

Step 1: Compute h(2,5,7,3)h(2, 5, 7, 3).
Here, p=2,q=5,r=7,s=3p = 2, q = 5, r = 7, s = 3.

p×q=2×5=10p \times q = 2 \times 5 = 10
r×s=7×3=21r \times s = 7 \times 3 = 21

Since (r×s)>(p×q)(r \times s) > (p \times q), the rule specifies taking the remainder of (r×s)/(p×q)(r \times s) / (p \times q):

remainder of 21/10=1.\text{remainder of } 21 / 10 = 1.

Thus, h(2,5,7,3)=1h(2, 5, 7, 3) = 1.

Step 2: Evaluate fg(h(2,5,7,3),4,6,8)=fg(1,4,6,8)fg(h(2, 5, 7, 3), 4, 6, 8) = fg(1, 4, 6, 8).
By the problem's definition, the composite function fghfgh is the product of ff, gg, and hh. Similarly, fgfg is the product of ff and gg:

fg(p,q,r,s)=f(p,q,r,s)×g(p,q,r,s)fg(p, q, r, s) = f(p, q, r, s) \times g(p, q, r, s)

For the input tuple (1,4,6,8)(1, 4, 6, 8):

f(1,4,6,8)=max⁡(1,4,6,8)=8f(1, 4, 6, 8) = \max(1, 4, 6, 8) = 8
g(1,4,6,8)=min⁡(1,4,6,8)=1g(1, 4, 6, 8) = \min(1, 4, 6, 8) = 1

Step 3: Multiply the two results:

fg(1,4,6,8)=8×1=8.fg(1, 4, 6, 8) = 8 \times 1 = 8.
Final answer

8

Common trap

Computing quotient instead of remainder in function hh, which would give 22 instead of 11.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2015 Computer Science and Information Technology (CS) Session 2
Question
9 of 65, printed as GA Q.9
Section
General Aptitude

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.