Min-heap MCQs

By: Prof. Dr. Fazal Rehman Shamil | Last updated: September 20, 2024

What is a Min-heap?

a) A binary tree where the value of each node is less than or equal to the values of its children
b) A binary tree where the value of each node is greater than or equal to the values of its children
c) A binary tree where the left subtree is less than the root and the right subtree is greater than the root
d) A binary tree with no restrictions on node values
Answer: a) A binary tree where the value of each node is less than or equal to the values of its children
Which operation in a Min-heap ensures that the heap property is maintained?

a) Insertion
b) Deletion
c) Both insertion and deletion
d) Traversal
Answer: c) Both insertion and deletion
What is the time complexity of finding the minimum element in a Min-heap?

a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: a) O(1)
In a Min-heap, which node has the smallest value?

a) Root node
b) Leaf nodes
c) Internal nodes
d) Any node
Answer: a) Root node
Which data structure is commonly used to implement a Min-heap?

a) Linked list
b) Array
c) Stack
d) Queue
Answer: b) Array
Which operation in a Min-heap removes and returns the minimum element?

a) Extract-Max
b) Extract-Min
c) Delete-Max
d) Delete-Min
Answer: b) Extract-Min
In a Min-heap with
𝑛
n elements, what is the height of the heap?

a) O(log n)
b) O(n)
c) O(n log n)
d) O(1)
Answer: a) O(log n)
Which operation in a Min-heap inserts a new element while maintaining the heap property?

a) Insert
b) Update
c) Replace
d) Swap
Answer: a) Insert
What is the array representation of a Min-heap?

a) An array where each element is greater than its parent
b) An array where each element is less than its parent
c) An array where each element is equal to its parent
d) An unordered array
Answer: b) An array where each element is less than its parent
Which traversal method can be used to print all elements of a Min-heap in sorted order?

a) In-order traversal
b) Pre-order traversal
c) Post-order traversal
d) Level-order traversal
Answer: d) Level-order traversal
What is the worst-case time complexity of inserting an element into a Min-heap with
𝑛
n elements?

a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: b) O(log n)
Which operation in a Min-heap swaps elements to maintain the heap property?

a) Swap-Min
b) Heapify
c) Balance
d) Adjust
Answer: b) Heapify
Which operation in a Min-heap decreases the value of a node and adjusts the heap if necessary?

a) Decrease-Key
b) Increase-Key
c) Modify-Key
d) Change-Key
Answer: a) Decrease-Key
Which traversal method of a Min-heap visits nodes level by level?

a) In-order traversal
b) Pre-order traversal
c) Post-order traversal
d) Level-order traversal
Answer: d) Level-order traversal
In a Min-heap, which operation retrieves the minimum element without removing it?

a) Peek-Max
b) Peek-Min
c) Peek-Root
d) Peek-Top
Answer: b) Peek-Min
Which operation in a Min-heap ensures that the heap property is restored bottom-up?

a) Bubble-Up
b) Bubble-Down
c) Trickle-Up
d) Trickle-Down
Answer: a) Bubble-Up
Which of the following is NOT true about Min-heaps?

a) The root element is always the minimum element
b) They are used in priority queues
c) They are a type of self-balancing tree
d) They are complete binary trees
Answer: c) They are a type of self-balancing tree
Which operation in a Min-heap removes and returns the minimum element, and then restructures the heap?

a) Remove-Min
b) Delete-Min
c) Extract-Min
d) Pop-Min
Answer: c) Extract-Min
In a Min-heap, what is the relationship between a parent node
𝑖
i and its children
2
𝑖
+
1
2i+1 and
2
𝑖
+
2
2i+2?

a) Parent is less than or equal to children
b) Parent is greater than or equal to children
c) Parent is equal to children
d) Parent is not related to children
Answer: a) Parent is less than or equal to children
Which operation in a Min-heap ensures that the heap property is restored top-down?

a) Bubble-Up
b) Bubble-Down
c) Trickle-Up
d) Trickle-Down
Answer: d) Trickle-Down

 

Data Structures MCQs

Basic Concepts

  1. Introduction to Data Structures
  2. Complexity Analysis MCQs

Linear Data Structures MCQs

  1. Arrays MCQs
  2. Linked Lists MCQs
  3. Stacks MCQs
  4. Queues MCQs

Non-Linear Data Structures MCQs

  1. Trees MCQs
  2. Heaps MCQs
  3. Graphs MCQs

Hashing MCQs MCQs

  1. Hash Tables

Sorting and Searching Algorithms MCQs 

  1. Sorting Algorithms MCQs
  2. Searching Algorithms MCQs

Miscellaneous

  1. Memory Management in data structures MCQs
  2. String Manipulation Algorithms MCQs
  1. Data Structures MCQs 1
  2. Data Structures MCQs 2
  3. Data Structures MCQs 3
  4. Data Structures MCQs 4
  5. Data Structures MCQs 5
  6. Stacks Solved MCQs
  7. Queues MCQs
  8. pointer mcqs
  9. Array MCQs