Question

Pouring water. We have three containers whose sizes are 10 pints, 7 pints, and 4 pints,...

Pouring water. We have three containers whose sizes are 10 pints, 7 pints, 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 allowed 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 pourings that leaves exactly 2 pints in the 7- or 4-pint container.

(a) Model this as a graph problem: give a precise definition of the graph involved and state the specific question about this graph that needs to be answered.


(b) What algorithm should be applied to solve the problem?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

3.8 (a) Let G = (V, E) be our (directed) graph. We will model the set of nodes as triples of numbers (a0, a1, a2) where the following relationships hold: Let S0 = 10, S1 = 7, S2 = 4 be the sizes of the corresponding containers. ai will correspond at the actual contents of the ith container. It must hold 0 ≤ aiSi for i = 0,1,2 and at any given node a0 + a1 + a2 = 11 (the total amount of water we started from). An edge between two nodes (a0, a1, a2) and (b0, b1, b2) exists if both the following are satisfied :

– the two nodes differ in exactly two coordinates (and the third one is the same in both).

– if i, j are the coordinates they differ in, then either ai = 0 or aj = 0 or ai = Si or aj = Sj.

The question that needs to be answered is wether there exists a path between the nodes (0, 7, 4) and (∗, 2, ∗) or (∗, ∗, 2) where ∗ stands for any (allowed) value of the corresponding coordinate.

(b) Given the above description, it is easy to see that a DFS algorithm on that graph should be applied, starting from node (0, 7, 4) with an extra line of code that halts and answers ‘YES’ if one of the desired nodes is reached and ‘NO’ if all the connected component of the starting node is exhausted an no desired vertex is reached.

(c) It is easy to see that after a few steps of the algorithm (depth 6 on the dfs tree) the node (2,7,2) is reached, so we answer ‘YES’.

Add a comment
Know the answer?
Add Answer to:
Pouring water. We have three containers whose sizes are 10 pints, 7 pints, and 4 pints,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • There are three containers whose size are 3 pints, 5 pints, and 7 pints, respectively. The...

    There are three containers whose size are 3 pints, 5 pints, and 7 pints, respectively. The 3-pint and 5-pint containers start out full of water, but the 7-pint container is initially empty. We are allowed 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 pourings that leaves exactly 6 pints in the 7-pint...

  • Pouring water. We have three containers whose size are 10 pints, 7 pints, and 4 pints, respective...

    Pouring water. We have three containers whose size are 10 pints, 7 pints, 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 allowed 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 pourings that leaves exactly 2 pints in...

  • You have a 10-liter container, a 7-liter container, and a 4-liter container. The large container is...

    You have a 10-liter container, a 7-liter container, and a 4-liter container. The large container is empty; the other two are full of water. You are challenged to rearrange the water, using as few operations as possible, so that there are exactly two liters in either the 7-liter or the 4-liter container. You are allowed to perform only one type of operation: pouring the contents of one container into another, stopping only when the source container is empty or the...

  • Recursion and Trees Application – Building a Word Index Make sure you have read and understood...

    Recursion and Trees Application – Building a Word Index Make sure you have read and understood ·         lesson modules week 10 and 11 ·         chapters 9 and 10 of our text ·         module - Lab Homework Requirements before submitting this assignment. Hand in only one program, please. Background: In many applications, the composition of a collection of data items changes over time. Not only are new data items added and existing ones removed, but data items may be duplicated. A list data structure...

  • 1. What is the definition of an 'equivalence point' in an acid/base titration? (1 point) 2....

    1. What is the definition of an 'equivalence point' in an acid/base titration? (1 point) 2. In part one of the experiment, you will prepare the acid solutions being titrated from a stock solution. Describe how you will accurately prepare 10.00 mL of 0.100 M HCl solution using a 1.00 M HCl stock solution. In your response to this question, be very specific about the quantities of stock solution and deionized water to be used in the dilution and the...

  • For the preparation and standardization of NaOH with KHP im supposed to boil water for 1hr and 30 min to remove CO2

    For the preparation and standardization of NaOH with KHP im supposed to boil water for 1hr and 30 min to remove CO2....the problem is that if I don't boil it for that long and (30 min) b/c of not enough time but I put the water I boiled for 1/2 hr aproximately into a NaOH bottle with a CO2 absorber and stored it there for a few days. I would assume that I would have to boil the water again...but...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

  • What happened on United flight 3411?What service expectations do customers have of airlines such ...

    What happened on United flight 3411?What service expectations do customers have of airlines such as United and How did these expectations develop over time? Thank You! In early April 2017, United Airlines (United), one of the largest airlines in the world, found itself yet again in the middle of a service disaster this time for forcibly dragging a passenger off an overbooked flight. The incident was to become a wake-up call for United, forcing it to ask itself what to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT