Question
Which data structure is most suitable for implementing a
priority queue?Solution
A binary heap is the most suitable data structure for implementing a priority queue because it allows for efficient extraction of the highest or lowest priority element. The time complexity for inserting and extracting elements is O(log n), making it highly efficient. Why Other Options are Wrong: a) Stack follows LIFO (Last In First Out) and cannot manage priority efficiently. b) Queue follows FIFO (First In First Out) and doesn’t handle priority. d) Linked list has linear time complexity for extracting elements based on priority. e) Array requires scanning the entire list for priority, leading to inefficient operations.
In a 5-stage pipeline (Fetch, Decode, Execute, Memory, Write-back), how many instructions can be in various stages of processing at the same time?
A transformer has a primary coil with 300 turns and a secondary coil with 150 turns. If the primary voltage is 240V, calculate the secondary voltage.
Which of the following is a common problem that synchronization mechanisms address in multi-threaded or multi-process environments?
What happens when a program accesses data that is not currently in physical memory (RAM) due to virtual memory management?
Which of the following is not a valid keyword in C++ language?
XML is designed to ____ and ____ data)
What is the main purpose of a digital signature in public key cryptography?
The best case time complexity of selection sort?
What is the space complexity of an algorithm?
Which functions are declared inside a class have to be defined separately outside the class?