Java Applets Centre

This applet demonstrates the basic operations on a stack data structure. The operations of "Push" and "Pop" take O(1) time.

Code (An array-based stack)

public void push(int val){
public void pop(){
  if(!isEmpty()) tos--;
public int top(){
  return s[tos];
public boolean isEmpty(){
  return (tos==-1)? true:false;

Data Structures and Algorithms
Java Applets Centre

R. Mukundan
Department of Computer Science
University of Canterbury
Private Bag 4800, Christchurch
New Zealand.