Exercise

Derive Savitch's Space Bound

Analyze recursive bounded reachability without charging for the whole recursion tree.

Assignment sources

Noy 2025 high-quality exam preparation and community solutionsCommunity solutionפתרון מטלה 6- סיבוכיות.pdfAssignment 6High-quality preparation and community solution — not official

Problem

A configuration graph has N≤2cs(n)N\le2^{c s(n)} vertices, each encoded in O(s(n))O(s(n)) bits. Analyze a deterministic recursive test for reachability within NN steps and show it uses O(s(n)2)O(s(n)^2) space.

Hint 1

Test a path of length at most 2ℓ2^\ell by trying each midpoint and making two recursive calls with parameter ℓ−1\ell-1.

Hint 2

The two calls and the different midpoint trials run sequentially. Charge one stack frame per recursion depth, not one per recursion-tree node.

Full solution

Define R(u,v,ℓ)R(u,v,\ell). At ℓ=0\ell=0, accept exactly when u=vu=v or one edge leads from uu to vv. Otherwise enumerate each configuration mm and accept if both R(u,m,ℓ−1)R(u,m,\ell-1) and R(m,v,ℓ−1)R(m,v,\ell-1) accept.

An induction proves that R(u,v,ℓ)R(u,v,\ell) accepts exactly when a path of length at most 2ℓ2^\ell exists: split any such path at its midpoint, and concatenate the two recursively witnessed half-paths in the converse direction.

Choose ℓ=⌈log⁡N⌉=O(s(n))\ell=\lceil\log N\rceil=O(s(n)). One frame stores a constant number of configurations, a midpoint counter, and ℓ\ell, totaling O(s(n))O(s(n)) bits. Memory is reused after each recursive return, so

S(ℓ)≤S(ℓ−1)+O(s(n)).S(\ell)\le S(\ell-1)+O(s(n)).

At depth O(s(n))O(s(n)), this gives S=O(s(n)2)S=O(s(n)^2).

Checkpoint

The algorithm may take enormous time. Savitch's theorem is a space simulation, and sequential exploration is what keeps space small.

Provenance note

This is an original walkthrough of the standard Savitch recurrence; student submissions are not evidence for correctness.

Common mistakes

  • Skipping a direction of correctness or an input-format edge case.
  • Measuring resources against a numeric value rather than encoded input length.
  • Treating an informal intuition as a proof of the stated bound.

Sources and verification

  • Merged summary, pp. 124-127
  • Sipser 3e, sec. 8.1
  • Arora-Barak draft, sec. 4.2
  • Catalog mapping: data/exercises.json; statements and solutions are independently written; personal submissions are non-authoritative.
Guided construction

Savitch recursion

Step 1 of 6
Savitch configuration graph and recursionThe graph 1 to 2 to 3 with an extra edge from 1 to 4 is coordinated with a depth-first recursion for REACH of 1, 3, and level 2.Implicit configuration graph1234witness path: 1 → 2 → 3 (2 ≤ 4)Depth-first recursionbounded call appears next
Witness pathActive stack frame