The assignment I have is to effectively write my own merge sort algorithm. I've started off fine but I'm having a bit of trouble working out exactly what I want to do, a crucial step in actually writing the code.
The idea is to use a recursive function:
sort(A){
split A
sort(A1)
sort(A2)
merge A1 and A2
}
(Obviously there are details that I haven't come onto yet, such as stopping if the size of A is < 1)
The part I'm having trouble with is not the theory, but rather the implementation and syntax of it.
When I *split* the array, I am not actually creating any new arrays. The issue here is that merging the lists is not possible in one array. Should I create a single new array for my final sorted list? And what exactly should my function be returning every time?