Stacks and Queues
Applications of Stacks
- Expression Evaluation Stack is used to evaluate prefix, postfix and infix expressions.
- Expression Conversion An expression can be represented in prefix, postfix or infix notation. Stack can be used to convert one form of expression to another.
- Syntax Parsing Many compilers use a stack for parsing the syntax of expressions, program blocks etc. before translating into low level code.
- Parenthesis Checking Stack is used to check the proper opening and closing of parenthesis.
- String Reversal Stack is used to reverse a string. We push the characters of string one by one into stack and then pop characters from stack.
Applications of Queues
- Serving Requests
- Serving requests on a single shared resource, like a printer, CPU task scheduling etc.
- In real life scenario, Call Center phone systems uses Queues to hold people calling them in an order, until a service representative is free. Handling of interrupts in real-time systems. The interrupts are handled in the same order as they arrive i.e First come first served.