Meet-in-the-Middle Search

Split an exponential search into two independently enumerable halves and turn pair enumeration into a lookup.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Factor the condition across a partition
  2. Trade auxiliary storage for a lower exponent

Factor the condition across a partition

In exact subset sum with \(n\) items, split them into two halves. Construct the subset-sum lists \(L\) and \(R\). There is a solution with total \(W\) exactly when \(s\in L\) and \(W-s\in R\). After sorting one list, test complements by binary search. For weights \((3,11,8,6)\) split at the middle, the lists contain \(11\) and \(6\), witnessing \(17\). Store each generating subset mask if the witness itself is required.

Trade auxiliary storage for a lower exponent

Each equal half has roughly \(2^{n/2}\) subsets. Enumeration and sorting cost \(O(n2^{n/2})\) under unit-cost operations on sums, with \(O(2^{n/2})\) stored entries. Large integers add bit complexity. This helps when \(W\) is huge and pseudopolynomial DP has too many states. The separable condition is essential. If many cross-half constraints must remain visible, complementary sums alone cannot represent compatibility. Exponent changes matter explicitly in fine-grained complexity.[1][2]

References

  1. Jeff Erickson, Algorithms ↩
  2. MIT OpenCourseWare, Design and Analysis of Algorithms: Lecture Notes ↩