Elements with same priority get processed according to Priority Queue mechanism - Data Structure

Q.  How are the elements with the same priority get processed according to the Priority Queue mechanism?
- Published on 19 Oct 15

a. Before the processing of other elements with lower priority
b. After the processing of other elements with highest priority
c. On the basis of 'First-Come-First Served' priority
d. None of the Above

ANSWER: On the basis of 'First-Come-First Served' priority
 

    Discussion

  • Nirja Shah   -Posted on 16 Nov 15
    Elements with the same priority get processed on the basis of 'First-Come-First Served' basis if the two elements have the same priority.
    Every element of priority queue has some priority, and elements are processed according to their priority. An element with higher priority will be processed first. If two elements have same priority, then element which comes first in the queue will be processed. Priority queue is used in CPU scheduling. In priority queue insertion is simple, elements are added at the rear end. For deletion operation, the element with highest priority is searched and deleted first. If you implement queue through sorted list then deletion of element is easy.
    struct node
    {
        int priority;
        int data;
        struct node ∗ link;
    }

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)