S
Seth G.
The following question is about merge sort, and not particularly java
( I didnt know where else to put this query).
If merge sort uses the divide and conquer approach to sort an array in
the following manner(roughly):
MERGE_SORT(Array,begin,end)
{
if ( begin < end )
{
middle = ( begin + end ) / 2
// merge sort first half of array
MERGE_SORT(Array,begin,end/2);
// merge sort second half of array
MERGE_SORT(Array,end/2,end);
MERGE(Array,begin,middle,end);
}
}
What effect would dividing by the array into more than 2 (say
3,4,...,n) have on the algorithm? Would it be more efficient than the
merge sort runtime of
O(n logn)? My inclination is to say no, and it may in fact be less
efficient due to the increased recursive calls to merge sort, pushing
larger chunks of data onto the stack.
I remeber speaking to someone about this very topic before, and I
cant recall the outcome of that conversation and why I convinced
myself it was no more efficient than merge sort "as is".
Thanks in advance!
( I didnt know where else to put this query).
If merge sort uses the divide and conquer approach to sort an array in
the following manner(roughly):
MERGE_SORT(Array,begin,end)
{
if ( begin < end )
{
middle = ( begin + end ) / 2
// merge sort first half of array
MERGE_SORT(Array,begin,end/2);
// merge sort second half of array
MERGE_SORT(Array,end/2,end);
MERGE(Array,begin,middle,end);
}
}
What effect would dividing by the array into more than 2 (say
3,4,...,n) have on the algorithm? Would it be more efficient than the
merge sort runtime of
O(n logn)? My inclination is to say no, and it may in fact be less
efficient due to the increased recursive calls to merge sort, pushing
larger chunks of data onto the stack.
I remeber speaking to someone about this very topic before, and I
cant recall the outcome of that conversation and why I convinced
myself it was no more efficient than merge sort "as is".
Thanks in advance!