by unwind · 4y ago · 0 comments
I'm certainly not a good theoretical computer scientist, but I did quickly google this and I couldn't find any trace of constant-time sorting (unless you goalpost it to have O(n log n) processors, but that is kind of cheating, here).
Wikipedia distinguishes two measures of space, "total" (including the input) and "auxiliary" (excluding the input). The poster above you is likely referring to auxiliary space.
def sort(self):
pass
def __getitem__(i):
suit = int(i / 13)
rank = i % 13
return f"{rank} of {('diamonds', 'hearts', 'spades', 'clubs')[suit]}"