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

You are given two jugs, a 4-gallon one and a 3-gallon one Neither has any measur

ID: 3850277 • Letter: Y

Question

You are given two jugs, a 4-gallon one and a 3-gallon one Neither has any measuring markers on it There is a tap that can be used to fill the jugs with water How can you get exactly 2 gallons of water into the 4-gallon jug? Use Depth -First search but after the initial {0, 0} state, continue your search from the {0, 3} successor instead of the {4, 0} successor. (Refer to you class notes). You are given two jugs, a 4-gallon one and a 3-gallon one. Neither has any measuring markers on it. There is a tap that can be used to fill the jugs with water. How can you get exactly 2 gallons of water into the 4-gallon jug? Use Breadth -First search i.e. finish expanding each row before going to the next one. It means expanding the {4, 0} followed by the {0, 3} states before going to their successors on the next row. (Refer to you class notes).

Explanation / Answer

Let us suppose one jug A is of 3-gallon and the other jug B is of 4-gallon.

1. Algorithm to solve (Depth first search)

water pouring steps

{0,0}->{3,0}->{0,3}->{3,3}->{2,4}

2. Algorithm to solve (Breadth first search)

water pouring steps

{0,0}->{4,0}->{1,3}->{1,0}->{0,1}->{4,1}->{2,3}

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