Comprehension

Directions for the next 2 questions: There are three bottles of water, A, B, C, whose capacities are 5 litres, 3 litres, and 2 litres respectively. For transferring water from one bottle to another and to drain out the bottles, there exists a piping system. The flow through these pipes is computer controlled. The computer that controls the flow through these pipes can be fed with three types of instructions, as explained below:

Instruction typeExplanation for the instruction
FILL (X, Y)Fill bottle labeled X from the water in bottle labeled Y, where the remaining capacity of X is less than or equal to the amount of water in Y.
EMPTY (X, Y)Empty out water in bottle labeled X into bottle labeled Y, where the amount of water in X is less than or equal to remaining capacity of Y.
DRAIN (X)Drain out all the water contained in bottle labeled X.

Initially, A is full with water, and B and C are empty.

Question: 1

After executing a sequence of instructions, bottle A contains one litre of water. The first and the third of these instructions are shown below: FILL (C, A)
______________________________
FILL (C, A) Then which of the following statements about the second instruction is true?

Show Hint

When solving container problems, track states (A, B, C) after each step to deduce unknown instructions.
Updated On: Jun 30, 2026
  • The second instruction is FILL (B, A).
  • The second instruction is EMPTY (C, B).
  • The second instruction transfers water from B to C.
  • The second instruction involves using the water in bottle A.
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Initial state: A = 5 L, B = 0 L, C = 0 L. Step 1: FILL (C, A) $\Rightarrow$ transfer from A to C until C full (capacity 2 L). A = 3 L, B = 0 L, C = 2 L. Step 2: To end up with A = 1 L after Step 3 (another FILL (C, A)), we must first empty C into B so that C becomes empty before Step 3. This is done by EMPTY (C, B) (capacity of B = 3 L). A = 3 L, B = 2 L, C = 0 L. Step 3: FILL (C, A) $\Rightarrow$ from A to C: transfer 2 L to fill C. A = 1 L, B = 2 L, C = 2 L. Condition satisfied: A has 1 L after Step 3. \[ \boxed{\text{Second instruction = EMPTY (C, B)}} \]
Was this answer helpful?
0
0
Question: 2

Consider the same sequence of three instructions and the same initial state mentioned above. Three more instructions are added at the end of the above sequence to have A contain 4 litres of water. In this total sequence of six instructions, the fourth one is DRAIN (A). This is the only DRAIN instruction in the entire sequence. At the end of the execution of the above sequence, how much water (in litres) is contained in C?

Show Hint

First find the state of the three bottles after the three given instructions, then see what two instructions after DRAIN (A) can put 4 litres into A.
Updated On: Nov 4, 2026
  • Zero
  • Two
  • One
  • None of these
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Step 1: Set up the rules:
Capacities: A = 5, B = 3, C = 2 litres. Write the water in the bottles as (A, B, C); the start is (5, 0, 0). FILL (X, Y) fills X completely from Y, and EMPTY (X, Y) pours all the water of X into Y.

Step 2: Recover the first three instructions:
The sequence of the previous question has FILL (C, A) as the first and the third instruction, and A holds 1 litre after the third. FILL (C, A) first gives (3, 0, 2). The third FILL (C, A) takes 2 litres out of A and needs C to be empty, so A = 1 afterwards means A was 3 before it. So the second instruction must empty C without using A: EMPTY (C, B) gives (3, 2, 0). Then FILL (C, A) gives (1, 2, 2). (A DRAIN (C) would also empty C, but the question says the fourth instruction is the only DRAIN.)

Step 3: Apply the fourth instruction:
DRAIN (A) gives (0, 2, 2).

Step 4: Use the last two instructions:
A must hold 4 litres after two more instructions. FILL (A, B) or FILL (A, C) is impossible, because A needs 5 litres to be filled and neither bottle holds that much. So both instructions must be EMPTY (B, A) and EMPTY (C, A): (0, 2, 2) becomes (2, 0, 2) and then (4, 0, 0), which is the only way to reach 4 litres in A.

Step 5: Read off the answer:
At the end, bottle C is empty: it contains 0 litres.

Final Answer:
The correct option is (1): Zero
Was this answer helpful?
0
0