Priority Queues and Heaps - Case Studies

Download Q&A
Q. If you have a priority queue implemented as a binary heap, what is the time complexity of finding the k-th smallest element?
  • A. O(k log n)
  • B. O(n)
  • C. O(k)
  • D. O(log n)
Q. In a max-heap, if the root node has a value of 20, what can be the maximum value of its children?
  • A. 10
  • B. 15
  • C. 20
  • D. 25
Q. In a max-heap, what is the relationship between the height of the heap and the number of elements?
  • A. Height is log(n)
  • B. Height is n
  • C. Height is n log(n)
  • D. Height is constant
Q. In a min-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 priority queue implemented with a binary heap, what happens when the maximum element is removed?
  • A. The last element is placed at the root
  • B. The root is replaced with the minimum element
  • C. The heap is restructured
  • D. Both A and C
Q. What is the primary advantage of using a binary heap over an unsorted array for implementing a priority queue?
  • A. Faster insertion
  • B. Faster deletion
  • C. Better memory usage
  • D. Easier implementation
Q. What is the time complexity of building a 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 extracting the minimum element from a min-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 min-heap?
  • A. O(1)
  • B. O(log n)
  • C. O(n)
  • D. O(n log n)
Q. Which data structure is commonly used to implement a priority queue?
  • A. Array
  • B. Linked List
  • C. Binary Search Tree
  • D. Heap
Q. Which of the following is NOT a valid operation for a priority queue?
  • A. Insert
  • B. Delete Min
  • C. Get Min
  • D. Sort
Q. Which of the following statements about heaps is true?
  • A. Heaps are always balanced
  • B. Heaps can be implemented using arrays
  • C. Heaps can only be binary
  • D. Heaps are not complete binary trees
Showing 1 to 12 of 12 (1 Pages)
Soulshift Feedback ×

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

Not likely Very likely