Branch and Bound - Job Selection
Algorithm
- Read jobs (id, deadline, profit).
- Sort jobs by profit in descending order.
- Use recursion for decision tree:
- include current job (if slot is available)
- exclude current job
- Before expanding a node, calculate upper bound (best possible profit from this point).
- If bound is not better than current best profit, prune that branch.
- At leaf level, update best answer if current profit is higher.
- Print maximum profit and selected jobs.
Why Branch and Bound
- Normal recursion checks many useless branches.
- Bound helps skip branches that cannot improve answer.
Complexity
- Worst case: exponential
- Usually faster than plain brute force due to pruning