algorithm - why is the standard merge sort not in place? -


in merge algorithm of merge sort, don't understand have use auxiliary arrays l, r? why can't keep 2 pointers corresponding element we're comparing in 2 subarrays l , r merge-sort algorithm remains inplace?

thanks.

say split array s.th. l uses first half of original array, , r uses second half.

then durign merge first few elements r smaller smallest in l. if want put them in correct place merge result, have overwrite elements l have not been processed during merge step yet.

of course can make diferent split. can construct such (then different) example.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -