Stooge sort is a recursive sorting algorithm and it doesn't use any temp arrays. So why is the space complexity O(n) and not O(1)?
def stoogesort(arr, l, h):
if l >= h:
return
# If first element is smaller
# than last, swap them
if arr[l]>arr[h]:
t = arr[l]
arr[l] = arr[h]
arr[h] = t
# If there are more than 2 elements in
# the array
if h-l + 1 > 2:
t = (int)((h-l + 1)/3)
# Recursively sort first 2 / 3 elements
stoogesort(arr, l, (h-t))
# Recursively sort last 2 / 3 elements
stoogesort(arr, l + t, (h))
# Recursively sort first 2 / 3 elements
# again to confirm
stoogesort(arr, l, (h-t))
Does the recursion have something to do with the space complexity of O(n)?