← Back to Games

šŸ’Ž Space Complexity Explorer

Visualize memory usage - each variable, array, and recursive call uses gems!

šŸ—ļø Memory Tower
šŸ’Ž
0
Memory Gems Used
O(1)
Space Complexity
Variables
(O(1) each)
Arrays
(O(N) each)
Recursion Stack
(Depth = O(?))
Objects/Matrices
(O(?) each)
Variable (1 gem)
Array (N gems)
Recursive Call
Object/Matrix
šŸ’» Current Code
Select a scenario to see the code...

šŸ“š Understanding Space Complexity

Space complexity measures the total memory used by an algorithm:

  • O(1): Fixed number of variables, regardless of input size
  • O(N): Memory grows linearly (e.g., creating array of size N)
  • O(N²): Memory grows quadratically (e.g., NƗN matrix)
  • Recursion: Each call adds to the call stack - depth determines space!
šŸ“‹ Select Scenario
Swap Variables
O(1)
Copy Array
O(N)
Recursive Sum
O(N)
Create Matrix
O(N²)
Binary Recursion
O(log N)
In-place Reverse
O(1)
šŸ“Š Memory Breakdown
Allocated Memory
No allocations yet 0 šŸ’Ž