Stack is a linear ADT, which follows a particular order while performing operations. This order is named LIFO (Last_in_First_Out).

We only have access to the top element of all the elements.

Practical Examples:

  1. Set of plates:

2. Piles of Books

Plates

You have access to the top element.

Usage

→ The forwards + backward operation in Web Browsers

→ Stock Span (A well-known financial Problem)

Stock Span Problem

→ NGE Problems Finding

→ Redo-Undo feature in Text-Editors, Picture editor, and so on….

→ Expression Conversion & Evaluation (Postfix to Infix, Postfix evaluation etc)

→ Backtracking (Maze Problems, Tree Traversal)

→ String Reverse

Implementation Techniques

There are two techniques:

Using Arrays (It has the disadvantage of the overflow of size)

Using Linked List (Extra memory taking, but efficient one)

Operations:

Mainly the following three basic operations are performed in the stack:

  • Push: Adds an item in the stack.
  • Pop: Removes an item from the stack. The items are popped in the reversed order in which they are pushed.
  • isEmpty: Returns true if the stack is empty, else false.

End Note

You can learn more about stack ADT (Implementations) from the Click.

Moreover, You can find some codes of the above problems from my Github Repo. Click

Thanks for Reading…..

On the way to be a Software Engineer | Love to write about Islamic & Programming Topics | Founder of Learn & Grow