QUEUE - 2 VHBJNKNK
QUEUE - 2 VHBJNKNK
QUEUE - 2 VHBJNKNK
1.
2.
3.
4.
EXAMPLE:
If FRONT = NULL
Write UNDERFLOW
Return
TEMP = FRONT
ITEM = INFO [TEMP]
FRONT = LINK [ TEMP]
Free (TEMP)
Return
EXAMPLE:
EXAMPLE:
PRIORITY QUEUE
A priority queue is a collection of elements such that each element has been assigned a priority
and such that the order in which elements are deleted and processed comes from the following
rules:
1) An element of higher priority is processed before any element of lower priority.
2) 2 elements with the same priority are processed according to the order in which they were
added to the queue.
Priority queues come in two forms
1. Max-priority Queue
2. Min-priority Queue
INSERTION:
ALGORITHM: This algo adds an ITEM with priority number N to a priority queue which is
maintained in memory as a one-way list.
1. If AVAIL = NULL
2.
Print OVERFLOW
3.
Return
4. NEW=AVAIL
5. INFO[NEW]=ITEM
6. PRN[NEW]=N
7. PTR = START
EXAMPLE:
DELETION
ALGORITHM: This algorithm deletes and processes the first element in a priority queue
which appears in memory as a one-way list:
1. ITEM=INFO[START]
2. TMP=START
3. START=LINK[START]
4. Free(TMP)
5. Exit/ Return
EXAMPLE:
2. Applications:
a) In Heaps
b) Max-priority queues: To schedule jobs on a shared computer etc.