sqrtspace-experiments/experiments/maze_solver
2025-07-20 03:56:21 -04:00
..
obj Initial 2025-07-20 03:56:21 -04:00
MazeGenerator.cs Initial 2025-07-20 03:56:21 -04:00
MazeResult.cs Initial 2025-07-20 03:56:21 -04:00
MazeSolver.cs Initial 2025-07-20 03:56:21 -04:00
MazeSolver.csproj Initial 2025-07-20 03:56:21 -04:00
MemoryLogger.cs Initial 2025-07-20 03:56:21 -04:00
plot_memory.py Initial 2025-07-20 03:56:21 -04:00
Program.cs Initial 2025-07-20 03:56:21 -04:00
README.md Initial 2025-07-20 03:56:21 -04:00
SimpleDemo.cs Initial 2025-07-20 03:56:21 -04:00
SpaceEfficientMazeSolver.cs Initial 2025-07-20 03:56:21 -04:00

Experiment: Maze Solver with Memory Constraints

Objective

Demonstrate Ryan Williams' 2025 theoretical result that TIME[t] ⊆ SPACE[√(t log t)] through practical maze-solving algorithms.

Algorithms Implemented

  1. BFS (Breadth-First Search)

    • Space: O(n) - stores all visited nodes
    • Time: O(n) - visits each node once
    • Finds shortest path
  2. DFS (Depth-First Search)

    • Space: O(n) - standard implementation
    • Time: O(n) - may not find shortest path
  3. Memory-Limited DFS

    • Space: O(√n) - only keeps √n nodes in memory
    • Time: O(n√n) - must recompute evicted paths
    • Demonstrates the space-time tradeoff
  4. Iterative Deepening DFS

    • Space: O(log n) - only stores current path
    • Time: O(n²) - recomputes extensively
    • Extreme space efficiency at high time cost

Key Insight

By limiting memory to O(√n), we force the algorithm to recompute paths, increasing time complexity. This mirrors Williams' theoretical result showing that any time-bounded computation can be simulated with √(t) space.

Running the Experiment

dotnet run                    # Run simple demo
dotnet run --property:StartupObject=Program  # Run full experiment
python plot_memory.py         # Visualize results

Expected Results

  • BFS uses ~n memory units, completes in ~n time
  • Memory-limited DFS uses ~√n memory, takes ~n√n time
  • Shows approximately quadratic time increase for square-root memory reduction

This practical demonstration validates the theoretical space-time tradeoff!