Skip to content

Latest commit

 

History

History
16 lines (10 loc) · 650 Bytes

stack.md

File metadata and controls

16 lines (10 loc) · 650 Bytes

Stack Data Structure

Stack is a list of data, where an item is inserted and extracted from the top. It is like a stack of Plates. The plate is always placed on the top, and taken away from the top. Since the last item is taken out first, it is also knos as Last In, First Out (LIFO) structure.

The insert and extract operation is constant time O(1), independent of the length of the stack.

A stack can be implemented in two ways:

  • Using Array
  • Using Linked List

In both cases the stacks will have the following functionalities:

  • Top -> Get the value of the last inserted input
  • Insert -> Push item on top
  • Delete -> Delete item from top