Understanding the difference between Queue and Stack

Untitled

Implementation of Stack using Arrays

Some points to remember:

  1. Declare and initialize an array → int[] arr = new int[1000];
  2. Initialize a pointer → int top = -1;
  3. void push( int element)

top = top + 1;

arr[top] = element;

  1. void pop() → top = top - 1;
  2. int top() → return arr[top]
  3. int size() → return top + 1;