1. : What is a stack in data structures?
(A) A data structure that allows random access
(B) A data structure that follows LIFO (Last In, First Out) principle
(C) A data structure that allows traversal from both ends
(D) A data structure that requires sorting before access
2. : Which operation adds an element to the top of the stack?
(A) Pop
(B) Peek
(C) Push
(D) Insert
3. : What happens when you pop an element from an empty stack?
(A) Stack becomes undefined
(B) Stack becomes null
(C) An error occurs
(D) Nothing happens
4. : What is the time complexity of the push operation in a stack implemented using an array with sufficient capacity?
(A) O(1)
(B) O(log n)
(C) O(n)
(D) O(n log n)
5. : Which operation removes and returns the top element of the stack?
(A) Push
(B) Pop
(C) Peek
(D) Remove
6. : What is the time complexity of the pop operation in a stack implemented using a linked list?
(A) O(1)
(B) O(log n)
(C) O(n)
(D) O(n log n)
7. : Which operation returns the top element of the stack without removing it? (A) Push
(B) Pop
(C) Peek
(D) Top
Answer: (C) Peek
8. : What happens when you peek an element from an empty stack?
(A) Stack becomes undefined
(B) Stack becomes null
(C) An error occurs
(D) Nothing happens
9. : What is the time complexity of the peek operation in a stack?
(A) O(1)
(B) O(log n)
(C) O(n)
(D) O(n log n)
10. : Which of the following statements is true about stack operations?
(A) Push and pop can be performed simultaneously
(B) Pop removes the bottom element of the stack
(C) Peek changes the stack size
(D) Push can be performed only once
11. : Which data structure is commonly used to implement a stack?
(A) Queue
(B) Array
(C) Linked list
(D) Tree
12. : In a stack, which operation modifies the size of the stack?
(A) Push
(B) Pop
(C) Peek
(D) None of the above
13. : What happens if you try to push an element onto a full stack (using an array implementation)? (A) The element is added at the top
(B) Stack becomes undefined
(C) An error occurs
(D) Nothing happens
Answer: (C) An error occurs
14. : Which operation is used to check if a stack is empty?
(A) isEmpty
(B) isFull
(C) size
(D) length
15. : What is the space complexity of a stack operation?
(A) O(1)
(B) O(log n)
(C) O(n)
(D) O(n log n)
16. : Which of the following statements is true about the stack data structure? (A) It allows elements to be accessed randomly
(B) It follows FIFO (First In, First Out) principle
(C) It is used for breadth-first search algorithms
(D) It is used for depth-first search algorithms
Answer: (D) It is used for depth-first search algorithms
17. : What is the primary limitation of using an array to implement a stack? (A) Limited capacity
(B) Slow access time
(C) Inefficient insertion and deletion
(D) Inability to perform push operation
Answer: (A) Limited capacity
18. : Which stack operation is responsible for decreasing the size of the stack? (A) Push
(B) Pop
(C) Peek
(D) None of the above
Answer: (B) Pop
19. : Which stack operation can be used to reverse the order of elements?
(A) Push
(B) Pop
(C) Peek
(D) None of the above
20. : In stack operations, what does the term “top” refer to?
(A) The element at the bottom of the stack
(B) The size of the stack
(C) The element at the top of the stack
(D) The middle element of the stack