How do we assign workers to tasks for the lowest total cost or time?
Solve assignment problems using the Hungarian algorithm to allocate agents to tasks for minimum total cost.
How to set up an assignment cost matrix and use the Hungarian algorithm (row and column reduction, covering zeros) to allocate agents to tasks for the lowest total cost.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
You must set up a cost matrix and apply the Hungarian algorithm to find the minimum-cost allocation.
The assignment set-up
You have agents and tasks, with a cost (or time) for each agent doing each task, recorded in a square cost matrix. The goal is a one-to-one allocation: each agent gets exactly one task and each task exactly one agent, with the smallest possible total cost.
The Hungarian algorithm
The method works by creating zeros that mark cost-free choices.
- Row reduction: subtract the smallest entry in each row from every entry in that row.
- Column reduction: subtract the smallest entry in each column from every entry in that column.
- Cover the zeros: cover all zeros using the fewest horizontal and vertical lines.
- Test: if the number of lines equals the matrix size , an optimal assignment exists among the zeros. If fewer, adjust and repeat.
- Adjust: find the smallest uncovered entry, subtract it from all uncovered entries, add it to entries covered twice, then re-cover.
Why row and column reduction works
Subtracting a constant from every entry of a row does not change which assignment is cheapest, because every complete allocation uses exactly one entry from that row, so all allocations lose the same amount. The same holds for columns. Reduction therefore preserves the optimal assignment while creating zeros that mark the locally cheapest choices. The algorithm then hunts for a set of these zeros, one in each row and column - an allocation costing zero in the reduced matrix, which corresponds to the minimum-cost allocation in the original. Understanding this invariance is what makes the procedure more than a recipe.
Unbalanced and infeasible problems
Two practical adjustments arise often. When the numbers of agents and tasks differ, the matrix is not square, so a dummy row or column of zeros is added to balance it; the agent or task matched to a dummy is simply left unassigned. When a particular agent cannot do a particular task, that cell is given a prohibitively large cost so the algorithm never selects it. Both adjustments let the standard square-matrix method handle real situations, and SACE questions frequently test whether you can set up the matrix correctly before reducing.
Reading off the allocation and cost
Once the zeros allow one selection per row and column, those zeros give the assignment. Read the total cost from the original matrix, not the reduced one.
Maximisation problems
If the table gives profits or scores to be maximised, first convert to a minimisation problem by subtracting every entry from the largest entry in the table, then run the Hungarian algorithm as normal. The resulting allocation maximises the original total.
Exam-style practice questions
Practice questions written in the style of SACE Board exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
SACE 20222 marksCalculator-assumed. Four buyers bid on four auction items. The original bid array has been transformed into a new array for the Hungarian algorithm. Explain what was done to the original array and why it is necessary.Show worked answer →
The auction is a maximisation problem (the charity wants the most money), but the Hungarian algorithm minimises. Each bid has been subtracted from the largest value in the array, converting it to an equivalent minimisation (opportunity-cost) array. (1 mark)
Subtracting every entry from the same constant reverses the ordering, so the highest bid becomes the smallest entry. Minimising the new array therefore maximises the original total, which is necessary because the algorithm only minimises. (1 mark)
SACE 20231 marksCalculator-assumed. Four children are allocated four chores with the Hungarian algorithm. When a fifth person is added, the array becomes 5 by 4. State why a dummy column of zeros must be added.Show worked answer →
The Hungarian algorithm requires a square array, with equal numbers of agents and tasks, so every row matches exactly one column.
With five people but four chores the array is 5 by 4; adding one dummy column makes it 5 by 5. The dummy column is filled with zeros because it represents a "no chore" assignment adding no time. The mark is for stating the array must be square.
SACE 20211 marksCalculator-assumed. The Hungarian algorithm is used to maximise the total training hours allocated to four apprentices. State one limitation of using the algorithm in this context.Show worked answer →
Any one valid limitation earns the mark. For example: the algorithm forces a strict one-to-one allocation, even if it would be better for one person to do two tasks; or it assumes the listed values are the only factor, ignoring availability, difficulty or aptitude; or it assumes every assignment is feasible when an apprentice may be unable to do a particular task.
