Name the ADT before the code
Define the abstract data type needed for a task before selecting an implementation.
The move: define the contract before the container. An abstract data type is a behavioral promise: the values it stores and the operations it supports. It does not say whether the implementation is an array, linked list, hash table, or tree. That separation is useful because the same visible behavior can be implemented many ways, and each implementation has a different cost profile. Contract Ask what callers must be able to do. Do they add at one end and remove from another? Do they look up by key? Do they preserve sorted order? Do they need uniqueness? This is the…
Sign up free — one personalized lesson every day, matched to your role and goals.
Already have an account? Sign in