Leaving Certificate Applied Mathematics2.9 Multi-stage problems and dynamic programming

All books

2.9 Multi-stage problems and dynamic programming — Practise

Work independently. The questions and answers are shown together at the end.

Show the value at every state, stage by stage from the last one backwards. A single final number with no table is worth few marks.

  1. A network has four stages. Stage 1 is AA; stage 2 is B,CB, C; stage 3 is D,ED, E; stage 4 is FF. The edges are AB=2AB = 2, AC=5AC = 5, BD=4BD = 4, BE=7BE = 7, CD=3CD = 3, CE=2CE = 2, DF=6DF = 6, EF=1EF = 1. Work backwards and find the least cost from DD to FF.
  2. For the same network, find the least cost from EE to FF, and from DD to FF.
  3. For the same network, find the least cost from BB to FF and from CC to FF.
  4. For the same network, find the least total cost from AA to FF and write down the route.
  5. In a dynamic programming problem, state what a stage and a state are.
  6. Explain why backward recursion starts at the last stage.
  7. On that network, a student at AA takes the cheaper first edge, AB=2AB = 2, and then has to pay 7+1=87 + 1 = 8 to finish, for a total of 10. What does this show?

Answers and concise solutions

1. Show the answer

1. Least cost from D to F

Answer: From DD there is only one edge forward, DF=6DF = 6, so the least cost from DD to FF is 66. Backward recursion always starts at the last stage, where the value is known directly.

2. Show the answer

2. Cost from E, then from D

Answer: From EE: only EF=1EF = 1, so the least cost is 11. From DD: only DF=6DF = 6, so the least cost is 66. Stage 3 is where the recursion begins.

3. Show the answer

3. Cost from B, then from C

Answer:

From BB: either B→D→FB \to D \to F at 4+6=104 + 6 = 10, or B→E→FB \to E \to F at 7+1=87 + 1 = 8. The least is 88, through EE. From CC: either C→D→FC \to D \to F at 3+6=93 + 6 = 9, or C→E→FC \to E \to F at 2+1=32 + 1 = 3. The least is 33, through EE.

4. Show the answer

4. Least total cost, then the route

Answer: From AA: either A→BA \to B then 88 more, at 2+8=102 + 8 = 10, or A→CA \to C then 33 more, at 5+3=85 + 3 = 8. The least total cost is 88, along A→C→E→FA \to C \to E \to F: 5+2+1=85 + 2 + 1 = 8.

5. Show the answer

5. Stage and state

Answer:

A stage is one step in the sequence of decisions — in a staged network, which column you are in. A state is the situation you can be in at that stage — in a staged network, which vertex you are at. Dynamic programming works because the best decision from a state does not depend on how you reached it. That is what lets the recursion run backwards from the last stage, where the value is known, to the first.

6. Show the answer

6. Why it starts at the last stage

Answer:

At the last stage the answer is known without any decision: the cost from a final vertex to the destination is just the edge to the destination, or zero if you are already there. Working backwards, each earlier stage is then solved using the values already found for the stage after it. Every value is computed once and reused, which is what makes dynamic programming efficient — it never solves the same sub-problem twice.

7. Show the answer

7. What the greedy choice shows

Answer:

It shows that taking the cheapest edge at each step — the greedy choice — does not always give the best total. AB=2AB = 2 is cheaper than AC=5AC = 5, but choosing it leaves only expensive ways to finish, for a total of 1010. Choosing the more expensive AC=5AC = 5 gives the better total of 88. Dynamic programming avoids this by looking at the whole remaining problem at each stage, rather than only the next edge. That is why it needs the values from the later stages before it can decide.

Settings

Colour scheme

Light or dark pages. Your colour and layout stay the same.

Colour

The paper, ink and lettering. Your layout stays the same.

Quiet colours
Bold colours
Layout

How pages are arranged. Your colours stay the same.

Reading offline

Keep this book on this device and read it offline.