understanding merge sort

J

josh

Here is the code (including the test).
http://pastebin.com/QH46wghT

it's working but i don't understand why this line:
merge_sort(a2)
works. I would think of doing this: a2 = merge_sort(a2) since i don't
see where are we assigning the return value of merge_sort into a2.

I guess there is something with recursion that I completely miss...
Thanks!
 
S

sreservoir

Here is the code (including the test).
http://pastebin.com/QH46wghT

it's working but i don't understand why this line:
merge_sort(a2)
works. I would think of doing this: a2 = merge_sort(a2) since i don't
see where are we assigning the return value of merge_sort into a2.

I guess there is something with recursion that I completely miss...
Thanks!

it's an in-place sort.
 
R

Robert Klemme

Maybe check out wikipedia, via googling merge sort.

Wikipedia is a good source. But I think a good book about algorithms
and data structures (e.g. Sedgewick) should be on anyone's shelve who is
doing programming.

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top