Tuesday, November 21, 2023

......... is very useful in situation when data have to be stored and then retrieved in reverse order


Answer: Stack

Stack is a simple linear data structure used for storing data.

Stack follows the LIFO (Last In First Out) strategy that states that the element that is inserted last will come out first.

To implement the Stack, it is required to maintain a pointer to the top of the Stack, which is the last element to be inserted. Elements of a stack can be accessed only on the top of the Stack.

Basic Stack Operations:

  • void push(data): an element is inserted into the stack with this operation.
  • int pop():   an element is removed from the top of the stack and is returned using this operation

Applications of the Stack

  1. A Stack can be used for expression evaluation consisting of operands and operators.
  2. Stacks can be used for Backtracking (to check parenthesis matching in an expression).
  3. Stack can also be used to convert one form of expression to another form (Polish Notations).
  4. Stack can be used for systematic Memory Management.

0 comments:

Post a Comment

Data Structures with C++



NET/SET/CS PG



Operating Systems



Computer Networks



JAVA



Design and Analysis of Algorithms



Programming in C++

Top