Stack operations (push, pop, peek) MCQsBy: Prof. Dr. Fazal Rehman | Last updated: May 14, 2025 20 Score: 0 Attempted: 0/20 Subscribe 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 Data Structures MCQs Basic Concepts Introduction to Data Structures Abstract Data Types (ADT) MCQs Complexity Analysis MCQs Time complexity MCQs Space complexity MCQs Big O, Big Ω, Big Θ notations MCQs Linear Data Structures MCQs Arrays MCQs One-dimensional arrays MCQs Multi-dimensional arrays MCQs Operations: traversal, insertion, deletion MCQs Linked Lists MCQs Singly linked list MCQs Doubly linked list MCQs Circular linked list MCQs Stacks MCQs Stack operations (push, pop, peek) MCQs Applications of stacks (expression evaluation, recursion) MCQs Queues MCQs Queue operations (enqueue, dequeue, front, rear) MCQs Types: Simple queue, circular queue, priority queue, deque MCQs Non-Linear Data Structures MCQs Trees MCQs Binary trees MCQs Binary Search Trees (BST) MCQs AVL Trees MCQs B-trees and B+ trees MCQs Tree traversal methods (in-order, pre-order, post-order) MCQs Heaps MCQs Min-heap MCQs Max-heap MCQs Heap operations (insertion, deletion, heapify) MCQs Applications of heaps (priority queues, heap sort) MCQs Graphs MCQs Graph representation (adjacency matrix, adjacency list) MCQs Graph traversal algorithms (DFS, BFS) MCQs Shortest path algorithms (Dijkstra’s, Bellman-Ford) MCQs Minimum Spanning Tree (Kruskal’s, Prim’s) MCQs Hashing MCQs MCQs Hash Tables Hash functions MCQs Collision resolution techniques (chaining, open addressing) MCQs Applications of hashing MCQs Sorting and Searching Algorithms MCQs Sorting Algorithms MCQs Bubble sort MCQs Selection sort MCQs Insertion sort MCQs Merge sort MCQs Quick sort MCQs Heap sort MCQs Searching Algorithms MCQs Linear search MCQs Binary search MCQs Interpolation search MCQs Miscellaneous Memory Management in data structures MCQs Dynamic memory allocation MCQs Garbage collection MCQs String Manipulation Algorithms MCQs Pattern matching (KMP, Rabin-Karp) MCQs String hashing MCQs Data Structures MCQs 1 Data Structures MCQs 2 Data Structures MCQs 3 Data Structures MCQs 4 Data Structures MCQs 5 Stacks Solved MCQs Queues MCQs pointer mcqs Array MCQs Related Posts:Stack Push Pop Traverse Implementation and Operations in Data Structures (C plus plus)Javascript Push Pop values in Stack Relational algebra, Union Operations, Binary Operations, Difference, Cartesian product Push notifications MCQsPush down automata PDA for b twice in theory of automataPush Down Automata - PDA