'How are recursive function calls of Merge stored in memory for this Python GeeksforGeeks Mergesort implementation?
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?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
