1. : What is a stack?
(A) A linear data structure that follows the Last In First Out (LIFO) principle
(B) A linear data structure that follows the First In First Out (FIFO) principle
(C) A non-linear data structure
(D) A type of queue
2. : What operation adds an element to the top of a stack?
(A) Enqueue
(B) Dequeue
(C) Push
(D) Pop
3. : What operation removes the top element from a stack?
(A) Enqueue
(B) Dequeue
(C) Push
(D) Pop
4. : What is the time complexity for the push operation in a stack?
(A) O(1)
(B) O(n)
(C) O(log n)
(D) O(n log n)
5. : What is the time complexity for the pop operation in a stack?
(A) O(1)
(B) O(n)
(C) O(log n)
(D) O(n log n)
6. : What is the main disadvantage of using an array to implement a stack?
(A) Fixed size
(B) Slow access
(C) Complexity in implementation
(D) None of the above
7. : Which of the following is true about a stack?
(A) Elements can be accessed in any order
(B) The last element added is the first to be removed
(C) It supports random access
(D) It is a non-linear data structure
8. : What is the result of popping from an empty stack?
(A) It returns NULL
(B) It causes an underflow error
(C) It returns zero
(D) It returns the top element
9. : What is the main application of stacks in programming?
(A) Implementing queues
(B) Function call management
(C) Sorting data
(D) Storing data in arrays
10. : Which of the following operations is NOT supported by a stack?
(A) Push
(B) Pop
(C) Peek
(D) Dequeue
11. : What does the peek operation do in a stack?
(A) Adds an element to the stack
(B) Removes the top element from the stack
(C) Returns the top element without removing it
(D) Clears the stack
12. : How is a stack typically represented in memory?
(A) Using arrays only
(B) Using linked lists only
(C) Using both arrays and linked lists
(D) Using trees
13. : What happens to the stack pointer when an element is pushed onto the stack?
(A) It moves up
(B) It moves down
(C) It remains unchanged
(D) It points to NULL
14. : What is the maximum size of a stack implemented using an array?
(A) Dynamic, can grow indefinitely
(B) Limited by the memory available
(C) Fixed at the time of declaration
(D) Depends on the programming language
15. : What is the primary use of the stack data structure in recursion?
(A) To store global variables
(B) To keep track of function calls
(C) To sort data
(D) To manage memory
16. : What will happen if you try to push an element onto a full stack?
(A) The stack will resize
(B) It will overwrite the bottom element
(C) It causes an overflow error
(D) The element will be ignored
17. : Which of the following scenarios can be solved using a stack?
(A) Balancing parentheses
(B) Reversing a string
(C) Depth-first search in graphs
(D) All of the above
18. : In which data structure do you use a stack to evaluate expressions?
(A) Queue
(B) Array
(C) Linked List
(D) Binary Tree
19. : Which of the following can cause a stack overflow?
(A) Using too much memory
(B) Too many recursive function calls
(C) Pushing elements onto a full stack
(D) Both B and C
20. : What is the space complexity of a stack implemented with a linked list?
(A) O(1)
(B) O(n)
(C) O(log n)
(D) O(n log n)
21. : Which of the following best describes a stack underflow?
(A) Adding elements to a full stack
(B) Removing elements from an empty stack
(C) Trying to access the top element without removing it
(D) None of the above
22. : How do you implement a stack using two queues?
(A) By using one queue for storing elements and the other for reversing the order
(B) By using one queue for pushing and one for popping
(C) By interleaving the two queues
(D) It cannot be done
23. : Which of the following is an application of a stack?
(A) Undo functionality in applications
(B) Traversing a tree
(C) Implementing a binary search
(D) All of the above
24. : What is the output of the following code if the stack is empty? stack.pop();
(A) It removes the last element
(B) It returns NULL
(C) It throws an error
(D) It does nothing
25. : What is the purpose of using a stack for parsing expressions?
(A) To evaluate expressions
(B) To store intermediate values
(C) To manage operator precedence
(D) All of the above
26. : How does a stack implemented with a linked list grow?
(A) It grows only when elements are added
(B) It can grow and shrink dynamically
(C) It has a fixed size
(D) It cannot grow
27. : What is a common way to implement a stack using an array?
(A) Using a circular queue
(B) By maintaining a top index
(C) By using a fixed size
(D) Both B and C
28. : Which of the following statements is true about a stack?
(A) It allows random access to elements
(B) The first element added is the first to be removed
(C) It is a last-in-first-out data structure
(D) It does not support the peek operation
29. : In a stack, what does it mean to “pop” an element?
(A) To remove the bottom element
(B) To remove the top element
(C) To view the top element
(D) To add a new element
30. : Which data structure can be used to implement recursion?
(A) Array
(B) Stack
(C) Queue
(D) Tree
31. : What is the effect of using delete on a stack node in C++?
(A) It frees the memory allocated for that node
(B) It only removes the data
(C) It causes a memory leak
(D) It does nothing
32. : What is the primary characteristic of a stack’s push and pop operations?
(A) They are executed in constant time
(B) They are executed in linear time
(C) They require sorting
(D) They require additional memory
33. : What is the main function of the “top” operation in a stack?
(A) To add an element
(B) To remove an element
(C) To view the top element without removing it
(D) To check if the stack is empty
34. : What is the relationship between stack and recursion?
(A) Stacks are not used in recursion
(B) Each function call in recursion uses a stack frame
(C) Recursion cannot be implemented using a stack
(D) Both are the same
35. : Which of the following describes the stack’s memory allocation?
(A) Stacks use dynamic memory allocation only
(B) Stacks can use both static and dynamic memory allocation
(C) Stacks use fixed memory allocation only
(D) Stacks do not require memory allocation