QUESTION 01
What is an ADT?
2 marksAnswer
An abstract data type specifies a collection of values and permitted operations by their behaviour, without requiring one particular storage representation.
QUESTION 01
An abstract data type specifies a collection of values and permitted operations by their behaviour, without requiring one particular storage representation.
QUESTION 02
An ADT describes what operations mean. An implementation supplies the concrete representation and algorithms.
A stack interface can provide push, pop, peek and is_empty. Its rule is last-in, first-out. A client should obtain the most recently pushed remaining value from pop, regardless of whether the stack uses an array or linked nodes.
An array stack can keep an element array and a top index. A linked stack can keep a head pointer and allocate nodes. Both can satisfy the same abstract rule, but have different capacity, allocation and locality properties. An ADT is not just a C struct declaration: behaviour is part of the definition.
The client can use operations without rewriting representation logic. Testing can verify observable behaviour. An implementation can be replaced while keeping a compatible contract. In C, headers and carefully designed functions support this separation, although C does not automatically enforce every abstraction boundary.
An ADT description should not be confused with an unconditional performance promise. The chosen implementation determines operation costs. Document those costs separately; for example, the array and linked stack versions shown later provide O(1) push/pop excluding allocator internals.