TYPE T
Stack{
T[] stack;
top = -1;
push(T data){
array size check;
stack[++top]= data;
}
T pop(){
empty check;
return stack[top--];
}
T peak(){
empty check;
return stack[top];
}
int size(){
return top+1;
}
}
TYPE T
Node{
T data;
Node next;
}
List{
Node front;
int size = 0;
addFirst(T data){
Node newNode = new Node(data, null);
newNode.next = front;
front = newNode;
size++;
}
T removeFirst(){
front null check;
T data = front.data;
front = front.next;
size--;
return data;
}
T peek(){
front null check;
return front.data;
}
int size(){
return size;
}
}
Stack{
List<T> stack;
push(T data){
stack.addFirst(data);
}
T top(){
data = stack.peek();
return data;
}
T pop(){
data = stack.removeFirst();
return data;
}
}