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:
- 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
- Find a N-digit number such that it is not divisible by any of its digits
- Area of the largest Rectangle without a given point
- Queries to check whether bitwise AND of a subarray is even or odd
- Find distinct integers for a triplet with given product
- Check if string remains palindrome after removing given number of characters
- Find an array of size N that satisfies the given conditions
- Count of pairs satisfying the given condition
- Partition the digits of an integer such that it satisfies a given condition
- C program for Time Complexity plot of Bubble, Insertion and Selection Sort using Gnuplot
- Program to print double headed arrow pattern

