Stack - Data Structure

Stack - Data Structure


2 min read



  • A stack is a linear data structure that stores items in a Last-In/First-Out (LIFO) manner.

  • A stack is typically implemented using an array or a linked list.

  • The basic operations that can be performed on a stack are:

    • Push: Adds an item to the top of the stack

    • Pop: Removes an item from the top of the stack

    • Peek: Returns the item at the top of the stack without removing it

  • Time Complexity:

    • Access -> at O(n).

    • Deletion at O(1).

    • Searching -> O(n)

    • Insertion -> O(1)

Where is Stack Useful?

Applications of Stacks

Stacks are widely used in many applications. Some of the common examples are:

  • The undo/redo functionality in text editors

  • Balancing symbols in programming languages

  • Backtracking in algorithms such as depth-first search

  • Function calls in programming languages

So this is it for this article. I hope it helped you somewhere. Don't forget to support us and share with other geekians.

Thank you, Have a nice day !!