Stack Data Structure

A.R
A.R
Nov 4 · 1 min read

Stack is first come last out.

Stack supports two basic operations called push and pop. The Push operation adds an element at the top of the stack, and the Pop operation removes an element from the top of the stack.

Stack is an ordered list in which, insertion and deletion can be performed only at one end that is called top.

Stack is a recursive data structure having pointer to its top element.

Applications of Stack

Recursion

Expression evaluations and conversions

Parsing

Browsers

Editors

Tree Traversals

Operations on Stack

There are various operations which can be performed on stack.

Push :

Adding an element onto the stack

Pop :

Removing an element from the stack

Peek :

Look all the elements of stack without removing them.

Other Stack Operations

Check if the stack is empty.

Find the size of the stack.

Search for an element in the Stack.

CODE OF STACK INTERFACE:

public interface Stack{

public Object peek();

public Object pop();

public void push(Object o);

public int size();

}

    A.R

    Written by

    A.R

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade