Heap operations (insertion, deletion, heapify) MCQsBy: Prof. Dr. Fazal Rehman | Last updated: May 15, 2025 20 Score: 0 Attempted: 0/20 Subscribe 1. : Which data structure is typically used to implement a heap? (A) Array (B) Linked List (C) Stack (D) Queue 2. : What is the time complexity of inserting an element into a heap of size 𝑛? (A) O(1) (B) O(log n) (C) O(n) (D) O(n log n) 3. : In a max-heap, which element is at the root? (A) Largest element (B) Smallest element (C) Median element (D) None of the above 4. : Which operation is used to maintain the heap property after an element is deleted from the heap? (A) Heapify (B) Merge (C) Sort (D) Search 5. : Which of the following is true about a min-heap? (A) The smallest element is at the root. (B) The largest element is at the root. (C) It is not possible to have duplicate elements. (D) Elements are not stored in any specific order. 6. : When inserting an element into a heap, which operation ensures that the heap property is maintained? (A) Bubble up (B) Bubble down (C) Swap with parent (D) Swap with child 7. : What is the worst-case time complexity of deleting the root element from a heap of size 𝑛? (A) O(1) (B) O(log n) (C) O(n) (D) O(n log n) 8. : Which type of heap is more commonly used in priority queue implementations? (A) Max-heap (B) Min-heap (C) Binary search heap (D) Fibonacci heap 9. : In a max-heap, which child of a node at index 𝑖 is the larger one? (A) Left child (2i) (B) Right child (2i + 1) (C) Either child, as both are equal (D) Neither child, as both are smaller 10. : What is the primary advantage of using a heap over a sorted array for implementing priority queues? (A) Faster search operations (B) Guaranteed constant-time insertion (C) Efficient removal of the maximum element (D) Ability to store duplicate elements 11. : Which operation is used to convert an unordered array into a heap? (A) Insertion (B) Deletion (C) Heapify (D) Merge 12. : What happens to the heap structure if an element is inserted into an already max-heap? (A) It remains unchanged. (B) It becomes a min-heap. (C) It gets sorted. (D) It might violate the heap property. 13. : Which condition is necessary to maintain during the heapify process? (A) Parent node should be greater than both child nodes. (B) Parent node should be less than both child nodes. (C) Parent node should be equal to both child nodes. (D) Parent node should be greater than or equal to both child nodes. 14. : What is the time complexity of building a heap from an array of 𝑛 elements? (A) O(n) (B) O(log n) (C) O(n log n) (D) O(n^2) 15. : Which operation is used to remove an arbitrary element from a heap? (A) Bubble up (B) Bubble down (C) Heapify (D) Extract min/max 16. : In a max-heap, what does the delete operation typically involve? (A) Deleting the root and replacing it with the smallest element (B) Deleting the root and replacing it with the largest element (C) Deleting the smallest element in the heap (D) Deleting the largest element in the heap 17. : Which data structure can efficiently implement both insertion and deletion operations in a heap? (A) Queue (B) Stack (C) Binary Tree (D) Priority Queue 18. : What is the index of the parent node of any node 𝑖 in a heap? (A) 𝑖/2 (B) 2*𝑖 (C) 𝑖−1 (D) 𝑖+1 19. : Which property ensures that a heap is a complete binary tree? (A) All levels are completely filled except possibly the last level, which is filled from left to right. (B) All levels are completely filled, regardless of the order. (C) All nodes have exactly two children. (D) All nodes are connected directly to the root. 20. : When deleting an element from a heap, what is the process used to maintain the heap property? (A) Bubble up (B) Bubble down (C) Swap with parent (D) Swap with child 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:Operations: traversal, insertion, deletion MCQsRelational algebra, Union Operations, Binary Operations, Difference, Cartesian product Deletion at the start, middle and end of the LinkedList in a single program in C++Memory management (stack, heap, static)(MCQs)Applications of heaps (priority queues, heap sort) MCQsMax-heap MCQs