Consider the following implementation of bucket-sort:
Algorithm BucketSort(S)
input: Sequence S of items with integer keys in range [0,N-1]
output: Sequence S sorted in nondecreasing order of keys.
let B be an array of N sequences, each of which is initially empty
for each item x in S do
let k be the key of x
remove x from S and insert it at the end of bucket (sequence) B[k].
for i←0 to N-1 do
for each item x in sequence B[i] do
remove x from B[i] and insert it at the end of S.
Is this implementation considered "In-Place"?
My textbook gives the following definition for "In-Place":
Remember that a sorting algorithm is in-place if it uses only a constant amount of memory in addition to that needed for the objects being sorted.
Now, I know the above algorithm uses O(n+N) memory, where N is the upper bound on the range. However, and I may be wrong, I think N would be a constant, even if it is a large one. So I'm guessing it is "in-place" per this definition but I'm unsure.
So given the above algorithm and definition of "in-place", is this implementation considered in-place?