Space Complexity
Learn Space Complexity (Foundations, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
What Is Space Complexity? Space complexity measures the extra memory an algorithm needs as the input size n grows. It counts the auxiliary space (new arrays, hash maps, recursion stack) and not the input itself. Like time complexity it is written in Big O: O(1) means a fixed number of variables, O(n) means memory that grows with the input.