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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if Pascal's Triangle is possible with a complete layer by using numbers upto N
- Count subarrays having sum of elements at even and odd positions equal
- Sorting algorithm visualization : Heap Sort
- Find position of non-attacking Rooks in lexicographic order that can be placed on N*N chessboard
- Split numbers from 1 to N into two equal sum subsets
- Check if a large number is divisible by a number which is a power of 2
- Find Nth number in a sequence which is not a multiple of a given number
- Check if given permutation of 1 to N can be counted in clockwise or anticlockwise direction
- Largest number M less than N such that XOR of M and N is even
- Maximize profit in buying and selling stocks with Rest condition
- Count of paths in given Binary Tree with odd bitwise AND for Q queries
- Proof that Clique Decision problem is NP-Complete | Set 2
- Count of subarrays of size K having at least one pair with absolute difference divisible by K-1
- Maximum sum of even indexed elements obtained by right shift on an even sized subarray
- Sorting algorithm visualization : Insertion Sort