Abstract data types(Implementation independent data structures) offer several advantages over concrete data structures:
Example:
Java's standard libraries supply several different implementations of its Map data type. The TreeMap implementation might be more efficient when a total ordering on the keys can be computed quickly but a good hash value is hard to compute efficiently. The HashMap implementation might be more efficient when hash values can be computed quickly and there is no obvious ordering on keys. The part of a program that creates a Map can decide which implementation to use. The parts of a program that deal with a created Map don't have to know how it was implemented; once created, it's just a Map.
If it weren't for abstract data types, every part of the program that uses a Map would have to be written twice, with one version to deal with TreeMap implementations and another version to deal with HashMap implementations.
Comments
Leave a comment