Computer Science
Write applications of Stack.
Python Stack
1 Like
Answer
The applications of Stack include:
- 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.
- Evaluation of Arithmetic Expressions — Stack is used to evaluate these arithmetic expressions on the basis of operator precedence.
- Processing Function Calls — The compilers use Stacks to store the previous state of a program when a function is called or during recursion.
- 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.
- Undo Mechanism in Text Editors — This operation is accomplished by keeping all text changes in a Stack.
Answered By
2 Likes