Priority queue - Quiz
  • 1. What is the typical underlying data structure used to improve priority queue performance?
A) Hash table
B) Heap
C) Queue
D) Stack
  • 2. What is the time complexity for insertions in a heap-based priority queue?
A) O(log n)
B) O(1)
C) O(n log n)
D) O(n)
  • 3. How long does it take to build a heap initially from n elements?
A) O(log n)
B) O(1)
C) O(n log n)
D) O(n)
  • 4. Which data structure is mentioned as a variant that can provide better bounds for some operations?
A) Fibonacci heaps
B) Queue
C) Linked list
D) Array
  • 5. What is the time complexity of building a tree from a sequence of n elements using a self-balancing binary search tree?
A) O(n)
B) O(1)
C) O(n log n)
D) O(log n)
  • 6. Why does a self-balancing binary search tree with a linked list require more storage?
A) It stores extra references to other nodes
B) It requires more complex metadata
C) It uses more memory per node due to pointers
D) It stores duplicate data
  • 7. From a computational-complexity standpoint, what are priority queues congruent to?
A) Sorting algorithms
B) Searching algorithms
C) Compression algorithms
D) Graph traversals
  • 8. What determines the order of service in a priority queue?
A) Data type size
B) Associated priority
C) Memory address
D) Insertion time
  • 9. How does a priority queue serve items?
A) Randomly
B) Highest priority first
C) First in first out
D) Last in first out
  • 10. In the Java standard library, which elements have the highest priority?
A) Lowest elements
B) Most recently added
C) Oldest elements
D) Highest elements
  • 11. Are priority queues and heaps conceptually the same?
A) No, heaps are never used for priority queues
B) No, they are distinct
C) Yes, they are identical
D) Yes, they are the same in all contexts
  • 12. What is the priority behavior in a stack implementation?
A) Undefined
B) Constant
C) Monotonically decreasing
D) Monotonically increasing
  • 13. What is the priority behavior in a queue implementation?
A) Static
B) Random
C) Monotonically decreasing
D) Monotonically increasing
  • 14. What happens if two elements have the same priority in some implementations?
A) The second is always ignored
B) Served in order of enqueuing
C) The order is strictly descending
D) They are discarded
Created with That Quiz — a math test site for students of all grade levels.