0

How do you go about solving this summation?:

$\sum_{i=2}^{n/2} (n-i)!$

Edit:

For context, I am trying to do an analysis of the average case time complexity of merge sort, measured based on the number of key comparisons done in merge sort.

I tried doing merge sort on small input arrays by hand and found that during the merging process, there are:


$2*(n-2)!$ combinations of subarrays that would result in n-1 number of key comparisons (one subarray has the largest element, the other has the second largest element)

$2*(n-3)!$ combinations of subarrays that would result in n-2 number of key comparisons (one subarray has the largest two element, the other has the third largest element)

$2*(n-4)!$ combinations of subarrays that would result in n-3 number of key comparisons (one subarray has the largest three element, the other has the fourth largest element)

...

$2*(n-(n/2)+1)!$ combinations of subarrays that would result in $(n/2)+1$ number of key comparisons (one subarray has all the largest elements, except for the smallest large element, while the other subarray has has all the smallest elements, except for the largest small element)

2 combinations of subarrays that would result in n/2 number of key comparisons


Based on these combinations, I would then find the probability for each number of key comparisons.

So in one merge, there should be [sum of (probability for i number of key comparisons) * (i number of key comparisons)] on average.

The average number of key comparisons for merge sort is then given by the recurrence equation:

W(1) = 0

W(n) = 2*W(n/2) + (average number of key comparisons in merging subarrays of size n/2)

I guess some assumptions that can (or should) be made are:

1) $n = 2^k$

2) the keys to be sorted are of unique values


Thank for the replies thus far. I hope this is a more complete question. Do point out any logical errors I've made.

NJHJ
  • 1
  • Factorial of fraction isn't possible. – delusional.existence Oct 13 '18 at 08:59
  • Please show us what you tried and where you got stuck. – Cecilia Oct 13 '18 at 09:01
  • 1
    To answer the question in the title: The general term is $(n-i)!$, but that has no connection to the question in the body, which is a bad thing. If $n$ is odd the upper bound of your summation isn't an integer, that's quite non-standard. Please edit the question to include your own work/thoughts. – Henrik supports the community Oct 13 '18 at 09:02
  • Assuming $n$ is even, then above sum can be expressed using terms described over here https://math.stackexchange.com/questions/227551/sum-k-1-2-3-cdots-n-is-there-a-generic-formula-for-this – nature1729 Oct 13 '18 at 09:20

0 Answers0