What are stacks? List 6 different applications of stacks in a computer system. (4)
Ans :
A stack is an abstract data type in which items are added to and removed only
from one end called TOP. For example, consider the pile of papers on your desk.
Suppose you add papers only to the top of the pile or remove them only from the
top of the pile. At any point in time, the only paper that is visible is the one on
the top. This structure is called stack. The six various application of stack in
computer application are:
1. Conversion of infix to postfix notation and vice versa.
2. Evaluation of arithmetic expression
3. Problems involving recursion are solved efficiently by making use of
stack. For example-Tower of Hanoi problem
4. Stack is used to maintain the return address whenever control passes from
one point to another in a program.
5. To check if an expression has balanced number of parenthesis or not.
6. To reverse string.
No comments:
Post a Comment