Why it matters

Meet-in-the-middle gives huge speedup for many exponential problems.

Advertisement

The architecture

Split input into halves.

Enumerate all subsets of each half.

Combine: for each subset of half 1, find matching in half 2.

Meet-in-middle techniqueSplit inputtwo halvesEnumerate each2^(n/2) eachCombinehash or sortn=40 doable with meet-in-middle (2^20); infeasible with 2^40
MITM technique.
Advertisement

How it works end to end

Subset sum: 2^(n/2) subsets in each; combine via sort + two pointer or hash.

Shortest path in graph up to 2^(n/2) states.

Complexity: memory O(2^(n/2)) too.