The Stack Abstract Data Type

Get an overview of stack operations and the data type you can use to implement a stack.

Stack ADT

The stack ADT is defined as a class that follows the LIFO principle for its elements. The stack should support the following operations:

  1. Push(): Adds a single element at the top of the stack
  2. Pop(): Removes a single element from the top of the stack.
  3. Top(): Reads the value of the top element of the stack (does not remove it).
  4. isEmpty(): Returns 1 if the stack is empty.
  5. Size(): Returns the number of elements in the stack.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy