Computer Science

Write applications of Stack.

Python Stack

1 Like

Answer

The applications of Stack include:

  1. Reversing a Word/Line — This can be accomplished by pushing each character on to a Stack as it is read. When the line is finished, characters are popped off the Stack and they will come off in the reverse order.
  2. Evaluation of Arithmetic Expressions — Stack is used to evaluate these arithmetic expressions on the basis of operator precedence.
  3. Processing Function Calls — The compilers use Stacks to store the previous state of a program when a function is called or during recursion.
  4. Backtracking — Backtracking is a form of recursion which involves choosing only one option out of the possibilities. Backtracking is used in a large number of puzzles like Sudoku and in optimization problems such as Knapsack.
  5. Undo Mechanism in Text Editors — This operation is accomplished by keeping all text changes in a Stack.

Answered By

3 Likes


Related Questions