What does ‘Space Complexity’ mean?
Space Complexity:
The term Space Complexity is misused for Auxiliary Space at many places. Following are the correct definitions of Auxiliary Space and Space Complexity.
Auxiliary Space is the extra space or temporary space used by an algorithm.
Space Complexity of an algorithm is total space taken by the algorithm with respect to the input size. Space complexity includes both Auxiliary space and space used by input.
For example, if we want to compare standard sorting algorithms on the basis of space, then Auxiliary Space would be a better criteria than Space Complexity. Merge Sort uses O(n) auxiliary space, Insertion sort and Heap Sort use O(1) auxiliary space. Space complexity of all these sorting algorithms is O(n) though.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Recommended Posts:
- Nodes with prime degree in an undirected Graph
- Sum and Product of all even digit aum Nodes of a Singly Linked List
- Number of ways to color N-K blocks using given operation
- Shortest Palindromic Substring
- Sum of N-terms of geometric progression for larger values of N | Set 2 (Using recursion)
- Rearrange array such that difference of adjacent elements is in descending order
- Find the Smallest number that divides X^X
- Maximum length Subsequence with alternating sign and maximum Sum
- Find and Count total factors of co-prime A or B in a given range 1 to N
- Longest Palindrome in a String formed by concatenating its prefix and suffix
- Minimize the maximum difference between adjacent elements in an array
- Minimum elements inserted in a sorted array to form an Arithmetic progression
- Check if a Sequence is a concatenation of two permutations
- Count of even and odd set bit with array element after XOR with K
- Find Next number having distinct digits from the given number N

