Describe stack operation

Briefly describe the term stack operation?

E

Expert

Verified

Stack is a data structure which follows Last in First out strategy.

Stack Operations:-

• Push – Pushes (inserts) the element in stack. The location is specified by pointer.
• Pop – Pulls (removes) the element out of stack. The location is specified by pointer
• Swap: - the two top most elements of stack can be swapped
• Peek: - Returns top element on stack but doesn’t remove it from the stack
• Rotate: - the topmost (n) items can be moved on stack in a rotating fashion

A stack has a fixed location in the memory when a data element is pushed in stack, pointer points to the current element.

   Related Questions in Data Structure & Algorithms

©TutorsGlobe All rights reserved 2022-2023.