In $k$-sorting array algorithms, every element is supposed to be $k$ positions from its correct positions. So with that in mind, if we used a randomized QuickSort, we will have $O(n\log{n})$. Now to prove a lower bound on this, we assume $k \le \frac n2$.
Question: Prove that you can not do better than $O(n\log n)$ on a $k$-sorted array.
Goal: I see here that the point is if we can prove that the lowest we can do is $\Omega(n\log n)$, then that would confirm that we can not do better than $O(n\log n)$ and that will finish the proof.
So, let us consider all possible permutations of $k$. Part of the solution reads:
Our goal is to prove a lower bound on the number of leaves in a decision tree for an algorithm that sorts an array in which every element is within $k$ positions of its proper position. We therefore provide a lower bound on the number of possible permutations that satisfy this condition.
Next, if we break the array into blocks of length $k$ (with a last block which is possibly smaller), each element will be at most $k$ positions from its correct place. For each full block there are $k!$ possible permutations, thus we have $(k!)^{\lfloor \frac nk \rfloor}$ total permutations of the entire array.
We can then prove a lower bound based on the number of leaves in the decision tree: the lower bound is the logarithm of the number of leaves, which is
$$\ge \log{(k!)^{\lfloor \frac nk \rfloor}} = \Omega(n\log k).$$
Problems:
- Why for proving a lower bound, we assume $k \le \frac n2$ in the first place? Why this factor specifically was taken into consideration, and why this contributes to finding a lower bound for any algorithm that works for $k$-sorted arrays?
- So, do we want to go over all permutations of $k$ so that we prove that for each permutation we can still do better than $O(n\log n)$, is this the goal? Is this why we want to consider all permutations based on $k$?
- How does $\ge \log{(k!)^{\lfloor \frac nk \rfloor}}$ fit in the whole analysis? Why did we start from this? We want to prove a lower bound for $k$-sorted arrays, namely that no algorithm can do better than $O(n\log n)$, so we want a lower bound that does not exceed that, thus we take permutations, which in turn corresponds to leaves in the decision tree. Can you please rephrase the whole approach in your own words? No solution is needed.