I need help understanding how the author got the answer of problem 11 in the Big O chapter.
The problem goes like this:
The following code prints
Printing the string is only an extra addition to the k time.
Checking whether each string is sorted is O(k) and say that printing it is O(dk) for some integer d (a constant). Adding the two we get O(k + dk), which can be re written as O(k(1 + d)). Because this just a scalar we know O(k + dk) = O(k) so the answer does not change.