Quote:
Originally Posted by splewis
Given an arbitrary adt array it's possible to prevent going out of bounds with a Length check.
Given an arbitrary adt trie it's not possible to prevent a lookup to a non-existing key based on any check - thus the lookups need to be safe.
|
This is exactly it.
(Yes, a KeyExists function and throwing on invalid keys would also be suitable for the error model, but you pay the hash and lookup penalty twice, so it is simpler in that case to do in one go.)
__________________