The space complexity is actually the additional space complexity used by your algorithm, i.e. the extra space that you need, apart from the initial space occupied by the data. Bubble-sort and insertion sort use only a constant additional space, apart from the original data, so they are O(1) in space complexity.

Answer from gdelab on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › time-complexities-of-all-sorting-algorithms
Time Complexities of all Sorting Algorithms - GeeksforGeeks
September 23, 2016 - Both are calculated as the function of input size(n). One important thing here is that despite these parameters, the efficiency of an algorithm also depends upon the nature and size of the input. Time Complexity is defined as order of growth of time taken in terms of input size rather than the total time taken. It is because the total time taken also depends on some external factors like the compiler used, the processor's speed, etc. Auxiliary Space is extra space (apart from input and output) required for an algorithm.
Discussions

How can a sorting algorithm have a space complexity of O(1)? - Stack Overflow
I'm learning about different sorting algorithms and their time/space complexities and saw that algorithms such as bubble sort and insertion sort have a space complexity of O(1). This struck me as ... More on stackoverflow.com
🌐 stackoverflow.com
Time and Space complexity of Radix Sort Algorithm
Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more. More on geeksforgeeks.org
🌐 geeksforgeeks.org
1
February 9, 2024
sorting - What is the space complexity of std::sort in the C++ Standard Template Library? - Stack Overflow
I always thought it the space complexity is O(1) but I looked online and it uses different sorting algorithms at different stages which has confused me, what exactly is the space complexity of std:... More on stackoverflow.com
🌐 stackoverflow.com
Big O Cheat Sheet: the time complexities of operations Python's data structures
Good for people getting into programming in general. I only have one remark: I wouldn't qualify O(n) as "Slow !" since it's still practically fast for low values of n and has the elegance of scaling linearly, which is one of the best scenarios available in the vast amount of cases a programmer will face. More on reddit.com
🌐 r/Python
28
209
April 16, 2024
🌐
Interview Kickstart
interviewkickstart.com › home › blogs › learn › time and space complexities of sorting algorithms explained
Time and Space Complexities of Sorting Algorithms Explained
December 22, 2024 - Since we are not using any extra data structure apart from the input array, the space complexity is O(1). Like selection sort, the insertion sort algorithm also divides the array into two parts: a subarray of already sorted elements and a subarray ...
🌐
Big-O Cheat Sheet
bigocheatsheet.com
Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!) @ericdrowell
This webpage covers the space and time Big-O complexities of common algorithms used in Computer Science. When preparing for technical interviews in the past, I found myself spending hours crawling the internet putting together the best, average, and worst case complexities for search and sorting algorithms so that I wouldn't be stumped when asked about them.
🌐
Medium
medium.com › @sylvain.tiset › a-journey-to-master-sorting-algorithms-6df575564699
A journey to master Sorting Algorithms | by Sylvain Tiset | Medium
October 31, 2024 - Time Complexity: it’s a measure ... average case and worst case scenario. Space Complexity: it’s the amount of memory required to execute the algorithm....
🌐
LeetCode
leetcode.com › discuss › post › 3191876 › Understanding-Time-and-Space-Complexity-of-Sorting-Algorithms
Understanding Time and Space Complexity of Sorting Algorithms - Discuss - LeetCode
In addition to time complexity, sorting algorithms also have space complexity, which refers to the amount of memory that the algorithm requires to sort the data.
Find elsewhere
🌐
Wikipedia
en.wikipedia.org › wiki › Sorting_algorithm
Sorting algorithm - Wikipedia
3 days ago - Of the algorithms described here, this is the first that scales well to very large lists, because its worst-case running time is O(n log n). It is also easily applied to lists, not only arrays, as it only requires sequential access, not random ...
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › g-fact-86
Space Complexity - GeeksforGeeks
The space Complexity of an algorithm is the total space taken by the algorithm with respect to the input size. Space complexity includes both Auxiliary space and space used by input.
Published   1 month ago
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › time-and-space-complexity-of-radix-sort-algorithm
Time and Space complexity of Radix Sort Algorithm - GeeksforGeeks
February 9, 2024 - The Radix Sort Algorithm has a time complexity of O(n*d), where n is the number of elements in the input array and d is the number of digits in the largest number. The space complexity of Radix Sort is O(n + k), where n is the number of elements ...
🌐
Programiz PRO
programiz.pro › resources › dsa-bubble-sort-complexity
Exploring Time Complexity and Space Complexity of Bubble Sort
This results in the average case time complexity of <katex>O(n^{2})</katex>. ... Bubble sort is an in-place algorithm—it sorts data directly within the array without additional memory, apart from a few variables used for swapping (swapped) and counting (i). The memory usage does not grow with the size of the input. Regardless of whether you are sorting 10 elements or 10,000, the same fixed amount of memory is used for the variables. Hence, the space complexity of bubble sort is O(1).
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › time-and-space-complexity-analysis-of-bubble-sort
Time and Space Complexity Analysis of Bubble Sort - GeeksforGeeks
July 23, 2025 - The space complexity of Bubble Sort is O(1). This means that the amount of extra space (memory) required by the algorithm remains constant regardless of the size of the input array being sorted.
🌐
Medium
devdiwan.medium.com › famous-sorting-algorithms-in-javascript-time-and-space-complexity-explained-bf2c6bfc7889
Famous Sorting Algorithms in JavaScript: Time and Space Complexity Explained | by Dev Diwan | Medium
January 24, 2025 - Sorting is a fundamental operation ... based on the size and characteristics of the data. In this article, we’ll explore famous sorting algorithms, their implementations in JavaScript, and their time and space complexities....
🌐
TalnCloud
taln.cloud › post › sorting-algorithms-what-are-they-and-how-to-use-them
Sorting Algorithms: What Are They and How to Use Them
Time complexity refers to the amount of time it takes for the algorithm to complete, while space complexity refers to the amount of memory used by the algorithm. Some sorting algorithms have a faster time complexity but a higher space complexity, ...
Price   $18 - $49
Address   Electronic City Phase 1, 560100, Bengaluru
(5.0)
🌐
WsCube Tech
wscubetech.com › resources › dsa › heap-sort
Heap Sort: Algorithm, Time Complexity, Examples (C, C++, More)
February 14, 2026 - Learn about Heap Sort Algorithm, its Time & Space Complexity, Code, Example. Understand how this efficient sorting technique works with detailed tutorial.
🌐
Analytics Vidhya
analyticsvidhya.com › home › complete guide on sorting techniques in python [2025 edition]
Complete Guide on Sorting Techniques in Python [2025 Edition] - Analytics Vidhya
November 28, 2024 - The time complexity of sorting ... O(nk) for Radix Sort. Space complexity measures the amount of memory used by an algorithm to solve a problem as a function of the input size....
🌐
Built In
builtin.com › data-science › bubble-sort-time-complexity
Bubble Sort Time Complexity and Algorithm Explained | Built In
The bubble sort algorithm may not be the most well-known or highly-regarded sorting algorithm, but it’s not a terrible option either. With a time complexity of O(n²) and a space complexity of O(1), it’s a simple algorithm that is easy for ...
🌐
Youcademy
youcademy.org › merge-sort-time-space-complexity
Time and Space Complexity of Merge Sort
No matter how the input is arranged, Merge Sort always divides the array into halves and merges them methodically. This consistency guarantees O(n log n) performance, unlike algorithms like Quick Sort, which can degrade to O(n²) in the worst case. Merge Sort has a space complexity of O(n).