Professional Documents
Culture Documents
Data Structures
Data structures are ways in which data is arranged in a
Queue
Linked list Binary Tree
Hash Table
Graphs
Stacks
Stacks
Stack is a data structure, which is a list of data elements, that
all insertions and deletions are made at one end. This is the TOP (Begin) of the Stack.
Elements are removed from a Stack in the reverse order of
Stacks
When we add an item to a Stack, we say that we PUSH it into the stack and when we remove an item, we say that we POP it from the stack.
Restricts Access
private double[]; private int maxSize; // (Length) private int top; // initially -1
Stack methods
stack (int s); // constructor
void push(double j); // put item on top of stack
double pop();
double peek();
bool isEmpty();
bool isFull();
Examples:
Internet web browsers storing addresses of recently
Constructor
public Stack(int s) // constructor { maxSize = s; stackArray = new double[maxSize]; top = -1; }
Thank you