def mergeSort(arr, l, r):
if l < r:
# Same as (l+r)//2, but avoids overflow for
# large l and h
m = l+(r-l)//2
# Sort first and second halves
mergeSort(arr, l, m)
mergeSort(arr, m+1, r)
merge(arr, l, m, r)
I'm a bit confused. I thought that just calling a function wouldn't change the value of arr unless I equated arr with the output of Mergesort ie arr=mergeSort(arr, l, m). What's the difference between calling a function where arr is modified vs calling a function where arr is modified and then subsequently setting arr to the output of the function?