Exam-style question
Try this first
Explain what data abstraction means. In your answer, describe how it applies to a stack that is implemented as an array and a pointer for the top of the stack.
Model answer
What a good answer should say
- Data abstraction is a methodology in which the details of how data is represented and constructed are hidden from the code that uses the data.
- A stack can be used as a stack without the user needing to know that its internal construction consists of an array and a pointer identifying the top of the stack.
- The use of the compound data object is therefore isolated from its implementation details.
Explanation
Why this works
A strong answer identifies both parts of the idea: the representation is hidden, and the way the object is used is separated from how it is constructed. The array and top-of-stack pointer provide the specified example of the hidden construction.
Common mistake
No common mistake is linked to this question yet.
