Unit summary
- A stack is LIFO, with push and pop at the top, held in an array or a linked list.
- Expressions can be infix, prefix or postfix, and a stack converts infix to postfix and evaluates postfix.
- Recursion solves a problem through smaller copies of itself, with a base case, using the runtime stack.
- Factorial, GCD, Fibonacci and Towers of Hanoi are classic recursive problems.
- A queue is FIFO, with insertion at the rear and deletion at the front.
- Circular queues reuse space, deques allow both ends, and priority queues serve by priority.
Glossary
| Term | Meaning |
|---|---|
| Activation record | The stack frame of a function call. |
| Base case | The case solved without recursion. |
| Circular queue | A queue whose array wraps around. |
| Deque | A double-ended queue. |
| Dequeue | Remove from the front of a queue. |
| Enqueue | Insert at the rear of a queue. |
| Infix | Operator between operands. |
| Overflow | Inserting into a full structure. |
| Polish notation | Another name for prefix notation. |
| Pop | Remove the top element of a stack. |
| Postfix | Operator after operands. |
| Prefix | Operator before operands. |
| Priority queue | A queue served by priority. |
| Push | Insert an element on a stack. |
| Queue | A FIFO linear structure. |
| Recursion | A function calling itself on a smaller problem. |
| Stack | A LIFO linear structure with one open end. |
| Underflow | Deleting from an empty structure. |
Question bank
Short Answer Questions (2 marks each)
- Define a stack.
- What is stack overflow?
- Convert A + B × C to postfix.
- What is Polish notation?
- Define recursion.
- What is the runtime stack?
- Define a queue.
- What is a circular queue?
- What is a deque?
- What is a priority queue?
Medium Answer Questions (5 marks each)
- Implement push and pop using an array.
- Implement a stack using a linked list.
- Convert (A + B) × C − D / E to postfix using a stack.
- Evaluate the postfix expression 6 2 3 + − 3 8 2 / + ×.
- Explain the Towers of Hanoi problem and its recursive solution.
- Implement a circular queue using an array.
Long Answer Questions (15 marks each)
- Explain stacks, their array and linked list representations, and their applications.
- Explain infix, prefix and postfix notation, the conversion of infix to postfix and the evaluation of postfix.
- Explain recursion and the runtime stack, with factorial, GCD, Fibonacci and Towers of Hanoi.
- Explain queues and their types: simple, circular, deque and priority queue, with their applications.
Sources
- Official BCA syllabus Data Structures, course code 25BCA402DS02, Unit III
