Algorithm | How Space Memory is Calculated | Corresponding Code
--------------------- | ----------------------------------------------- | ------------------------------------------------------------------
BFS | Max number of nodes in queue + explored set | max_memory = max(max_memory, len(frontier) + len(explored))
DFS | Max number of nodes in stack + explored set | max_memory = max(max_memory, len(frontier) + len(explored))
UCS | Max size of priority queue + explored cost dict | max_memory = max(max_memory, len(frontier) + len(explored_cost))
IDS | Max stack size across all DLS iterations | max_total_memory = max(max_total_memory, memory)
A* | Max size of priority queue + g_scores | max_memory = max(max_memory, len(frontier) + len(g_scores))
Hill Climbing | Only current node + neighbors | max_memory = max(max_memory, len(explored))
Genetic Algorithm | Population size stored in memory per generation | population = [...] → len(population)