Some “Hard” Problems are Easy
Example: Given a set of fields of a structure of length f1, f2, … ,fn in bytes. Can they be fit into two cache lines of length b bytes each.
Critical observation: b is small, often 32 or 64.
Algorithm: Use the subset sum algorithm to find the largest c < b such that some subset of the fields fits exactly into c bytes. You will need the method of reporting a solution from the decision problem to report a subset that adds up to c. The remaining field lengths must sum to be < b.