No, at least in models where the elementality of cells for n elements requires time Ξ© (n log n).
Consider the following data structure, which I am describing with Python.
class SpecialList: def __init__(self): self.lst = [] def append(self, x): self.lst.append(x) def rotationalsimilarity(self, k): rotatedlst = self.lst[k:] + self.lst[:k] count = sum(1 if x == y else 0 for (x, y) in zip(self.lst, rotatedlst)) self.lst = [] return count
It is clear that append and rotationalsimilarity (since it clears the list) are depreciated by O (1). If rotationalsimilarity were the worst O (1), then we could provide an O (1) undo operation that restores the data structure to its previous state. It follows from this that we could realize the elementality in time O (n).
def distinct(lst): slst = SpecialList() for x in lst: slst.append(x) for k in range(1, len(lst)): # 1 <= k < len(lst) if slst.rotationalsimilarity(k) > 0: return False slst.undo() else: return True
source share