Advanced Java Tutorial


Total available pages count: 55
Subject - Java Technologies

Stack

A stack is a linear data structure with an abstract data type that depicts Last in First Out (LIFO) behavior. It can be implemented as an array or LinkedList. We can insert & delete elements in the stack from the top-end only. Inserting elements in the stack is called pushing & deleting elements from the stack is called popping.

Stack defined as a container in which insertion & deletion can be done from one end calls as a top of the stack.

  • Kind of abstract data type with a pre-defined capacity
  • Follows some order to do insertion & deletion of an element in order of LIFO or FILO
  • A Top element can be accessed

Limitations

  • No more flexible
  • Manipulation is restricted to the top element of the stack

Operations

  1. push() - Insert element in the stack, an overflow condition occurs when the stack is full
  2. pop() - Delete an element from the stack, underflow condition occurs when the stack has no element that exists
  3. isEmpty() - determined if the stack is empty or not
  4. isFull() - determined if the stack is full or not
  5. peek() - return the element at peel position
  6. count() - return the total number of elements available in a stack
  7. change() - change element on change position
  8. display() - print all the elements available in the stack
     


Comments