In a circular queue implemented using an array of size 5, if the front is at index 3 and the rear is at index 1, how many elements are present in the queue?
3
1
4
2
What is the time complexity of inserting an element into a priority queue implemented using a binary heap (in the average case)?
O(log n)
O(n)
O(n log n)
O(1)
Which real-world scenario is best represented using a priority queue?
Managing a print queue where documents are printed in the order they are received
Maintaining a list of recently used applications
Storing a history of visited web pages in a browser
Scheduling tasks in an operating system based on their priority levels
In Dijkstra's algorithm, how does a priority queue help in finding the shortest path?
It stores all possible paths and their lengths
It prioritizes nodes based on their distance from the source node
It optimizes the relaxation step by providing efficient updates
It keeps track of visited nodes to avoid cycles
When implementing a circular queue, what happens when you try to enqueue an element into a full queue?
An error is thrown, preventing the operation
The enqueue operation is blocked until space becomes available
The oldest element is overwritten to make space
The queue dynamically resizes to accommodate the new element
Which data structure is commonly used to implement a priority queue where efficient insertion and removal of the highest-priority element are crucial?
Binary Heap
Binary Search Tree
Hash Table
Doubly Linked List
In a priority queue, elements with the same priority are dequeued in what order?
Random order
The order they were enqueued
Sorted order based on an additional attribute
It depends on the specific priority queue implementation
How can you prevent a queue implemented using a linked list from encountering an overflow condition?
Use a fixed-size array instead of a linked list
Use a circular linked list
Linked list implementation inherently prevents overflow
Implement a check for available memory before each enqueue operation
Which of the following operations is NOT efficiently supported by a standard queue data structure?
Dequeue from the front
Get the front element
Search for a specific element
Enqueue at the rear
In a priority queue implementation using a sorted array, what is the time complexity of the dequeue operation in the worst-case scenario?