Means-Ends Analysis
Means-ends analysis is a strategy built on one repeated question:
What is the difference between where I am now and where I want to be — and what action reduces that difference?
You apply it over and over. Each action shrinks the gap. When the gap reaches zero, you're done.
The three ingredients
Every means-ends problem needs:
| Ingredient | Meaning |
|---|---|
| Current state | Where things are right now |
| Goal state | Where you need them to be |
| Operators | The legal actions available to change the state |
If you can't state all three clearly, you can't apply the strategy — and that's often the real difficulty. Writing them down is most of the work.
The procedure
- Describe the current state and the goal state.
- Identify the biggest difference between them.
- Find an operator that reduces that difference.
- If the operator can't be applied yet, make its precondition a new sub-goal and solve that first.
- Apply the operator. Repeat from step 2.
Step 4 is the one students skip, and it's where the power lies. When an action isn't yet available, you don't abandon it — you set up a smaller problem whose solution makes it available. This is what produces the nested, recursive feel of means-ends analysis.
Why it matters for programming
This is how a large program actually gets written. You don't type it start to finish. You state where the data is, state where it needs to be, and repeatedly ask which transformation closes the gap. Each answer becomes a function.
It's also the strategy behind the Tower of Hanoi, which appears in the KTU classroom exercises for this module.
The characteristic weakness
Means-ends analysis is greedy about differences: it attacks the biggest gap first. Sometimes closing the biggest gap makes a smaller one impossible to close later, and you get stuck.
Tower of Hanoi shows this — occasionally you must move a disc away from its final position to make progress. A student who only ever reduces the visible difference will get stuck there.