I need both questions FUlly explained AND TYPED You are given two jugs, a 4-gall
ID: 3850258 • Letter: I
Question
I need both questions FUlly explained
AND TYPED
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 10, 3) successor instead of the {4, 0} successor. 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.Explanation / Answer
Only one question is answered per request .
I will try to explain in such a way that you may be able to solve both the questions.
There are two jugs let us say A having capacity of 4 litres and B having capacity of 3 litres.
Question 1 asks us to traverse the solution graph using DFS and following the path (0,0)-->(0,3). Similarly Question 2 asks us to traverse the solution graph using BFS and following the path (0,0)-->(4,0).
Please note that in this question (0,3) means A is empty and B is full. Similarly (0,0) means both A and B are empty.
Let us try to create all possibilities using a graph.
The above graph shows two ways by which we can get exactly 2 litres in jug A. Below is step wise explanation.
Answer 1: DFS via path (0,0)—>(0,3) :
Thus DFS will be :
In the same way you can traverse the graph using BFS.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.