Page 50 - Data Structures Interactive Book
P. 50
5.7 Exercise
Essay Questions
1. Implement a stack using arrays and demonstrate push, pop, and peek operations.
2. Write a program to check if a string of parentheses is balanced using a stack.
3. Convert an infix expression to postfix using a stack and evaluate it.
4. Implement a stack using linked lists and demonstrate insertion and deletion.
5. Explain how stacks are used in recursion with an example program.
6. Discuss the limitations of stacks and suggest scenarios where they are most effective.
Multiple Choice Questions (MCQ)
Q1. What is the main characteristic of a stack?
a) First-In First-Out (FIFO) b) Last-In First-Out (LIFO)
c) Random access of elements d) Elements stored in contiguous memory only
Q2. Which of the following operations is NOT associated with stacks?
a) Push b) Pop c) Peek/Top d) Enqueue
Q3. What is the time complexity of push and pop operations in a stack?
2
a) ( ) b) (log ) c) (1) d) ( )
Q4. Which of the following applications use stacks?
a) Round-robin scheduling b) Expression evaluation
c) Database indexing d) Graph traversal using BFS
Q5. How are stacks used in recursion?
a) To store function calls and local variables b) To store global variables only
c) To store arrays dynamically d) To store linked list nodes
Q6. Which of the following is a limitation of stacks?
a) They cannot store multiple data types
b) They have limited memory and can overflow
c) They cannot be implemented using linked lists
d) They cannot be used in expression evaluation
Q7. Which of the following correctly describes the result of popping from an empty stack?
a) Underflow b) Overflow
c) Segmentation fault always d) Null pointer exception
50

