Exercises — Branch and bound
Ten graded problems, from "can you spot the vocabulary" up to "design a bound yourself." Every one has a full worked solution hidden inside a collapsible callout — try first, then reveal. Prerequisites live in Branch and bound, with side-trips to Backtracking, Greedy Algorithms, 0-1 Knapsack, and Travelling Salesman Problem.
Level 1 — Recognition
Goal: can you read the vocabulary without tripping.
L1.1 In a minimization B&B, you have an incumbent (best complete solution so far) with cost . A live node has lower bound . Do you keep it or prune it?
Recall Solution L1.1
The lower bound is the most optimistic (cheapest) any completion of that node could be. Here even the best case, , is worse than the we already own. So we prune. Rule ::: For minimization, prune when . Since , prune.
L1.2 In a maximization B&B (like 0-1 Knapsack), incumbent value . A node has upper bound . Keep or prune?
Recall Solution L1.2
Upper bound is the most optimistic (biggest) value inside the node: . That is greater than , so the subtree might hold something better. Keep it (insert into live set). Rule ::: For maximization, prune only when . Here , so keep.
L1.3 Match each strategy to its data structure: FIFO B&B, LIFO B&B, Least-Cost B&B.
Recall Solution L1.3
FIFO B&B ::: Queue (BFS order — oldest node first) LIFO B&B ::: Stack (DFS order — newest node first) Least-Cost B&B ::: Priority queue (best bound first)
Level 2 — Application
Goal: turn the definitions into numbers.
L2.1 0-1 Knapsack, capacity . Items (value, weight): A(40,2), B(30,5), C(50,10), D(10,5). Compute the root upper bound using the fractional-fill rule.
Recall Solution L2.1
Why fractional fill: allowing fractions relaxes the hard "0 or 1" constraint, so its optimum is always the integer optimum — a valid over-estimate. Densities : A , B , C , D . Order A, B, C, D.
- Take A fully: profit , weight used , capacity left .
- Take B fully: profit (total ), weight , capacity left .
- C weighs but only fits → take fraction . Answer ::: root upper bound .
L2.2 Same instance. Compute the bound of the node "exclude A" (A forced out; nothing else decided). Capacity still .
Recall Solution L2.2
A is gone, so fill from B, C, D in density order.
- B fully: , weight , capacity left .
- C weighs , only fits → fraction . Answer ::: exclude-A bound .
L2.3 A complete feasible solution has value and weight . After it becomes incumbent, is the exclude-A node (bound ) pruned?
Recall Solution L2.3
Incumbent (maximization). Exclude-A upper bound . Even its best case cannot beat . Verdict ::: Pruned — a whole subtree gone in one comparison.
Level 3 — Analysis
Goal: reason about why a bound is valid or an ordering is smart.
L3.1 For TSP with the cost matrix below (symmetric, cities 1–4), compute the 2-min lower bound. A "" is the diagonal (no self-loop).
Recall Solution L3.1
Why two cheapest edges per city: in any tour each city has exactly one edge in and one out, so it contributes at least its two smallest incident edges. Summing them over-counts each edge twice, hence the . Two cheapest incident edges per city:
- City 1:
- City 2:
- City 3:
- City 4: Sum . Lower bound . Answer ::: .
L3.2 Now force edge (cost ) into the tour. Recompute the 2-min lower bound. Should it be the previous bound? Explain.
Recall Solution L3.2
Forcing an edge removes freedom, so the bound can only rise or stay equal. City 1 must use edge as one of its two; its next cheapest is → contributes (unchanged, since were already the two cheapest). City 2 must use ; next cheapest is → contributes (unchanged too). Cities 3, 4 unchanged: . Sum , LB . Observation ::: LB stays here because edge was already among both cities' two cheapest; forcing it added no new constraint. The bound can only go up or stay — never down.
L3.3 Least-Cost (LC) B&B always expands the live node with the best bound. Argue why LC tends to find the optimum faster than FIFO or LIFO B&B.
Recall Solution L3.3
The bound is the most promising possible value inside a node. Expanding the best-bounded node first means we chase the region most likely to contain the true optimum, so we discover a strong incumbent early. A strong incumbent is a tighter threshold, which prunes more of the remaining tree. One-line reason ::: LC reaches a good incumbent sooner, and a good incumbent prunes harder — see A* Search for the same "best-first" idea with an admissible heuristic.
Level 4 — Synthesis
Goal: run a small tree end-to-end and combine moves.
L4.1 Run LC B&B on the knapsack of L2.1 (; A(40,2), B(30,5), C(50,10), D(10,5)) until you can name the optimum and its value. Show which nodes get pruned.

Recall Solution L4.1
Order A, B, C, D by density. Incumbent starts at .
- Root bound (L2.1). Branch on A.
- Include A (): fill B fully (), C fraction → bound .
- Exclude A (): bound (L2.2).
- LC picks Include-A (bound ). Branch on B.
- Include A,B (): C fraction → bound . D doesn't fit meaningfully.
- Include A, exclude B (): C fraction → bound .
- Push toward completion of : remaining capacity ; C () and D () don't fit → complete solution , value , weight . Incumbent .
- Now prune every live node with bound : Exclude-A (bound ) is killed. The Include-A/exclude-B node (bound ) survives but its best real completion is ? Check weight: — infeasible; , — none beats , so it dead-ends without improving. Optimum ::: , value , weight .
L4.2 For the same instance, verify by brute force that really is optimal (list feasible subsets).
Recall Solution L4.2
Feasible subsets (weight ) and values:
- : w , v
- : w ✗
- : w ✗
- : w , v
- : w ✗
- : w , v
- : w , v
- ties nothing higher. Max feasible value ::: at — matches B&B. ✅
Level 5 — Mastery
Goal: design a bound and defend it.
L5.1 You must solve a minimization assignment: assign workers to jobs, cost matrix , each worker one job. Propose a valid lower bound for a partial assignment (some workers already assigned) and prove it is optimistic.
Recall Solution L5.1
Bound design. Let = cost already committed by assigned workers. For each unassigned worker , add the minimum cost over jobs still free: . Why optimistic (proof sketch): any completion assigns each unassigned worker to some free job at cost . Summing these minima can only under-count the true completion cost (it ignores the constraint that two workers can't share a job). So any real completion → valid lower bound for minimization. Prune when ::: .
L5.2 Numerically: with workers unassigned and free jobs having per-worker minimums and , and committed cost , what is the bound? If the incumbent is , is the node pruned?
Recall Solution L5.2
Incumbent (minimization). Since , the node's best case cannot beat what we hold. Verdict ::: , and pruned.
L5.3 Contrast this row-minimum bound with the Dynamic Programming / brute-force worst case. What does B&B actually improve?
Recall Solution L5.3
Row-minimum LB is cheap ( to compute) and prunes many partial assignments in practice. But if are nearly equal, few nodes get pruned and B&B explores close to all assignments. Takeaway ::: B&B improves the average/practical runtime through pruning; the worst case stays exponential ( here). It is a smarter exhaustive search, not a polynomial guarantee — see Big-O Notation.
Recall One-line self-test
Prune a node exactly when its ::: best-possible value (bound) cannot beat the incumbent — for minimization, for maximization.