Hello,
I’m a little dumbfounded to see the time complexity for the given solution is described as O(n) when I would expect it to be O(n log n). I was hoping somebody here could help me see the light.
The input (n) is recursively divided in halves and merged. Each merge operation takes linear time and their input size halves at deeper recursion levels but the number of merge operations doubles at at the same time, effectively taking O(n) at each depth level of the recursion tree. Since we keep recursing log n times I understand it as n log n.
What am I missing?
Thanks