Priority Queues and Heaps - Problem Set

Download Q&A
Q. How can you convert an array into a binary heap?
  • A. Insert elements one by one
  • B. Use the heapify process
  • C. Sort the array
  • D. Reverse the array
Q. If you have a min-heap, what will be the time complexity to extract the minimum element?
  • A. O(1)
  • B. O(log n)
  • C. O(n)
  • D. O(n log n)
Q. If you want to implement a priority queue that allows for efficient decrease-key operations, which data structure would be most suitable?
  • A. Binary Heap
  • B. Fibonacci Heap
  • C. Array
  • D. Linked List
Q. In a binary heap, how many children does each node have at most?
  • A. 1
  • B. 2
  • C. 3
  • D. 4
Q. In a max-heap, which of the following is true about the parent and child nodes?
  • A. Parent is always greater than children
  • B. Parent is always less than children
  • C. Parent can be equal to children
  • D. None of the above
Q. In a max-heap, which of the following statements is true?
  • A. The parent is always less than the children
  • B. The parent is always greater than the children
  • C. The children can be greater than the parent
  • D. All elements are in sorted order
Q. What is the maximum number of elements in a binary heap of height h?
  • A. 2^h
  • B. 2^(h+1) - 1
  • C. h + 1
  • D. h^2
Q. What is the time complexity of building a binary heap from an array of n elements?
  • A. O(n)
  • B. O(log n)
  • C. O(n log n)
  • D. O(n^2)
Q. What is the time complexity of inserting an element into a binary heap?
  • A. O(1)
  • B. O(log n)
  • C. O(n)
  • D. O(n log n)
Q. What is the worst-case time complexity for deleting the minimum element from a binary min-heap?
  • A. O(1)
  • B. O(log n)
  • C. O(n)
  • D. O(n log n)
Q. Which of the following algorithms can be used to sort an array using a binary heap?
  • A. Quick Sort
  • B. Merge Sort
  • C. Heap Sort
  • D. Bubble Sort
Q. Which of the following is NOT a characteristic of a binary heap?
  • A. Complete binary tree
  • B. Heap property
  • C. Sorted order of elements
  • D. Dynamic size
Q. Which of the following is NOT a property of a binary heap?
  • A. Complete binary tree
  • B. Heap order property
  • C. Balanced tree
  • D. Each node has at most two children
Q. Which of the following operations can be performed in O(1) time on a max-heap?
  • A. Insert
  • B. Delete Max
  • C. Get Max
  • D. Heapify
Q. Which of the following operations can be performed in O(1) time on a priority queue implemented with a binary heap?
  • A. Insert
  • B. Delete Min
  • C. Get Min
  • D. Decrease Key
Showing 1 to 15 of 15 (1 Pages)
Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely