
Space complexity of bubble sort refers to the amount of additional memory required by the algorithm to perform its operations. In the case of bubble sort, the space complexity is O(1), meaning that the algorithm sorts the elements in place without requiring any extra space proportional to the input size. This makes bubble sort a space-efficient sorting algorithm.

Space complexity of bubble sort refers to the amount of additional memory required by the algorithm to perform its operations. In the case of bubble sort, the space complexity is O(1), meaning that the algorithm sorts the elements in place without requiring any extra space proportional to the input size. This makes bubble sort a space-efficient sorting algorithm.
What is the space complexity in algorithms?
It measures the amount of extra memory an algorithm needs beyond the input data, typically expressed as Big-O.
What is the space complexity of bubble sort?
O(1) extra space — it sorts in place and uses only a fixed number of variables (e.g., indices and a temporary swap variable).
Why is bubble sort considered in-place?
Because it rearranges the input array without needing an extra array or data structure proportional to the input size.
What does O(1) space mean in this context?
The extra memory required does not grow with input size; a constant amount of memory is used regardless of n.