0

If I use the gap from shell with always lowering gap=n/2 how can I simply get the math behind the complexity. I know and read all other questions here but it doesn't seem obvious to me.

What I got until now:

For shell (every gap before 1, so before insertion sort starts) we have is

 n/2, n/4, n/8,..., 1

and for insertion sort we have

n^2

This together means:

n^2+(n^2)/2 + (n^2)/4 + ,..., + 2n^2

So this together means I have a worst-case of O(n^2)?

Is that correct so far?

How can I prove that?

chepner
  • 497,756
  • 71
  • 530
  • 681
buchstabe
  • 65
  • 1
  • 9
  • Shell sort complexity is a very tough nut to crack. I believe the overall complexity is a fractional power between 1 and 2 (so 3/2 or thereabouts, but not as simple as 3/2). The pattern of the gaps can affect that complexity, IIRC. – Jonathan Leffler Nov 21 '16 at 20:59
  • Thank you. But can anybody here tell me if I am on the right way. The duplicate link does not help my for MY problem. – buchstabe Nov 21 '16 at 21:17

0 Answers0