9618 · 10.4
Introduction to Abstract Data Types (ADT) — FAQ
Frequently asked questions for 9618 Introduction to Abstract Data Types (ADT). Direct answers first, then deeper explanation — then practise with marking.
Why not just always use the data structure directly? Why add the 'abstract' layer?
Using an ADT decouples the logic of your main program from the specific implementation of the data storage. This has huge benefits. If you find that your array-based queue is too slow, you can swap it out for a more efficient linked-list implementation without changing a single line of code in your main program, as long as the interface (ENQUEUE, DEQUEUE, etc.) remains the same. This makes your code more modular, maintainable, and reusable.
Are ADTs only used in Object-Oriented Programming (OOP)?
No, while OOP languages like Java or C# have features like classes, private members, and public methods that map very naturally to the concepts of encapsulation and information hiding, the principles of ADTs can be applied in any programming paradigm. In a procedural language like C or Pascal, you can implement an ADT by grouping related data in a struct or record and providing a set of functions that operate on a pointer to that structure, effectively creating a public interface.