liveBook · Manning

Cost

As explained in Algorithms Every Programmer Should Know

A cost is a quantity representing the expense or disadvantage associated with a preference or match.

A cost measures the expense or disadvantage of a match. In allocation, each worker–task pairing has a cost, such as distance, resources, or time; the goal is to choose pairings with the lowest total cost. section 3.1

Putting costs to work

A student could weigh university preferences using distance, while a company could compare the hours developers need to complete different modules. section 2.3.4 section 3.1

Figure 3.1 Cost matrix is created with the rows representing the workers and the columns representing the tasks. The values in the matrix denote the cost to complete the task. The cost can be replaced by other factors based on the use case like time taken, amount of work, or any other measurable value.

A cost matrix places workers in rows and tasks in columns, with each cell showing the cost of that pairing. section 3.1

How Algorithms Every Programmer Should Know covers it

How deep it goes
Represents each worker–task pairing with a fixed cost based on distance, resources, or time.
Examples
Uses university distance, chores, and developer-module hours to illustrate matching costs.
What you can do after
Evaluate assignments by adding their pairing costs and identifying the lowest-cost total.
How it connects
Connects cost to matching, preferences, weights, and the linear sum assignment problem.

Also explained in

Compare how 17 books explain cost →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Algorithms Every Programmer Should Know. The section links point to the parts of the book it draws on.