Assume a sorted list of $n$ elements followed by $f(n)$ elements in random order.
How would you sort the whole list given the following:
a) $f(n)=O(1)$
b) $f(n)=O(\log n)$
c) $f(n)=O(n^{1/2})$
d) How big can $f(n)$ be for the list to remain sortable in $O(n)$ time?
I hope somebody can help, thanks in advance.
I am assuming f(n) is the number of unordered elements in the list. I don't understand the significance of O of f(n), so maybe I don't understand the problem.
You can sort the unordered elements separately using a sort O(f(n) log f(n)) and then merge them with the ordered elements in an O(n) operation. In order to sort the entire list in O(n) time, I believe the unordered list would have to be already sorted, so f(n) would have to be 0 or 1.