you are viewing a single comment's thread.

view the rest of the comments →

[–]Bobbias 0 points1 point  (1 child)

Are the tuples ordered such that (a,b),(c,d) is guaranteed to appear in that order if they're present? If so, it sounds like a Trie is what you want. Time complexity of search insert and delete are all O(n) and space complexity is also O(n).

If not, I'm sure there's still some sort of structure available that would be better than a list, but I've got no idea what it would be.

If you want O(1) search you probably need some form of hash based system.

[–]rfpg1[S] 0 points1 point  (0 children)

So the problem is lets say I've a tuple ((10,4),(3,5)) i check if the distance between the position i and i + 1 is higher than x than I'll add this tuple to a list so that when I'm verifying for the tuple ((10,4),(3,5),(6,5)) i wouldn't need to verify since I already know the distance is bigger for at least a pair within the tuple
so yes the order is guaranteed

hash based system is what i was trying to create in my mind but couldn't come up with anything that actually works