Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Pouring water. we have three containers whose size are 10 pints , 7pints, and 4

ID: 3639915 • Letter: P

Question

Pouring water. we have three containers whose size are 10 pints , 7pints, and 4 pints respectively. The 7-pint and 4-pint containers start out full of water, but the 10-pint container is initially empty. we are all owed one type of operation pouring the contents of one container into another, stopping only when the source container is empty or the destination container is full. we want to know if there is a sequence of pouring that leaves exactly 2 pints in the 7- or 4-pint container.

1-what algorithm should be applied to solve the problem ?

Explanation / Answer

consider the notation as : (0,0,0) as containers : (4,7,10)
so initially (4,7,0)

1) transfer from 7 to 10 : (4,0,7)

2) transfer : (1,0,10)

3) empty : (1,0,0)

4) transfer : (0,0,1)

5) fill : (4,0,1)

6) fill :(4,7,1)

7) transfer : (4,0,8)

8) transfer : (2,0,10)

9) empty : (2,0,0)

The algorithm to be implemented is :

1) fill in the targeted pints.

2) transfer them to others so that some amount remains as difference exist.

3) check for the full capacity - existing amount = difference.

4) if that difference is the target, then transfer the remaining from the required to the full the other to get the required difference amount and hence the solution.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote