Understanding the difference between Queue and Stack

Implementation of Stack using Arrays
Some points to remember:
- The Traversal is in Last In First Out(LIFO) → Top to bottom
- Top() in C++, Peek() in Java → used to access the top element of the stack without removing it.
- Pop() only deletes the top element in C++, Pop() delete the element and also returns it in Java
- Declare and initialize an array →
int[] arr = new int[1000];
- Initialize a pointer →
int top = -1;
- void push( int element)
top = top + 1;
arr[top] = element;
- void pop() →
top = top - 1;
- int top() →
return arr[top]
- int size() →
return top + 1;