Hello,
As per the Code in the video, we are using the concept of Recursion to sort an Array/List. The Quicksort(A, l, r) takes on the array A as input and sorts it in-place. Here, the term in-place is a significant reason why we use return() and not return(A[l:r]) as done in the Mergesort.
To be more precise, when we pass on an Array to a function, we pass on the reference to the original array. Thus, when this array gets modified in the body of the function, it is the original itself which is getting modified. Thus, we need not return the array again.
As opposed to this case, if we pass on any other data type such as int or float to a function, we should be returning the modified data type since the original reference does not get modified.
Coming to the Mergesort code, observe that we use return arr since we are obtaining another array from the merge function which we use to merge two divided and sorted arrays. Since Merge sort is not an in-place sorting algorithm, we need to return the new array.
Hence, whenever we use any algorithm on lists that modifies the list in-place, we need not return the array. However, if the algorithm does not modify the list in-place or gives out a new list, we have to return that list.
Hope this helps.
Regards,
Hrishikesh