
























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

























Advantages of Modularity
Low Data Coupling
ADT interface is a specification of the values and operations that has two specific properties:
As the following diagram shows these two areas are completely independent. It is possible to take the implementation developed for one application and use it in another:
Pre-conditions: The stack exists, and element is of appropriate type Post-conditions: Element is put onto the top of the stack Inputs: A stack and an element Outputs: A changed stack Algorithm: Insert the element into the stack Here we are adding an element to the data structure. We need to conform to our ADT definition so the element will be inserted at the top of the structure.
Pre-conditions: Stack is not empty Post-conditions: The top element has been removed from the stack Inputs: The stack Outputs: The changed stack, ie top element, has been removed Algorithm: Remove the top element of the stack; give a copy of the element back to the user Here we are removing the last element that we added to the stack.
Pre-conditions: A stack exists Post-conditions: returns true if empty, false otherwise Inputs: a stack Outputs: boolean value In order to check if the stack is empty we need to look at the value held in the Top variable. If this is NULL then the stack is empty. If it is any other value then the stack cannot be empty. Note : It is important that we initialize the value of Top when we create the stack, otherwise we may have a value in here even though the stack is technically empty.