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?
2
4
3
1
In Dijkstra's algorithm, how does a priority queue help in finding the shortest path?
It optimizes the relaxation step by providing efficient updates
It prioritizes nodes based on their distance from the source node
It keeps track of visited nodes to avoid cycles
It stores all possible paths and their lengths
How does a circular queue determine if it is full?
Rear pointer reaches the end of the array
A separate variable keeps track of the number of elements
Front pointer equals rear pointer
Front pointer is one position behind the rear pointer (considering wrapping)
Which of the following data structures can be efficiently used to implement a priority queue?
Doubly Linked List
Binary Search Tree
Hash Table
Binary Heap
You are designing a system where elements are added and removed from both ends. Which data structure is the most suitable?
Deque
Stack
Queue
Binary Tree
In a priority queue implementation using a sorted array, what is the time complexity of the dequeue operation in the worst-case scenario?
O(n log n)
O(n)
O(log n)
O(1)
Which real-world scenario is best represented using a priority queue?
Scheduling tasks in an operating system based on their priority levels
Storing a history of visited web pages in a browser
Maintaining a list of recently used applications
Managing a print queue where documents are printed in the order they are received
Which of the following operations is NOT efficiently supported by a standard queue data structure?
Search for a specific element
Get the front element
Dequeue from the front
Enqueue at the rear
In a priority queue, elements with the same priority are dequeued in what order?
The order they were enqueued
Random order
It depends on the specific priority queue implementation
Sorted order based on an additional attribute
In the context of Breadth-First Search (BFS), how does a queue help explore a graph?
It ensures that nodes are visited in a depth-first manner.
It facilitates visiting all neighbors of a node before moving to the next level.
It stores the path from the source node to the current node.
It maintains a list of visited nodes to prevent cycles.