6. PRIORITY QUEUE | Array representation - the idea | Data Structure Full Course

Опубликовано: 18 Октябрь 2024
на канале: PSN Academy
172
like

One-Way List Representation of a Priority Queue:
One way to maintain a priority queue in memory is by means of a one-way list, as follows:
(a) Each node in the list will contain three items of information: an information field INFO, a
priority number PRN and a link number LINK.
(b) A node X precedes a node Y in the list (1) when X has higher priority than Y or (2) when
both have the same priority but X was added to the list before Y. This means that the order in
the one-way list corresponds to the order of the priority queue.
Priority numbers will operate in the usual way: the lower the priority number, the higher the priority.

Array Representation of a Priority Queue:
Another way to maintain a priority queue in memory is to use a separate queue for each level of
priority (or for each priority number). Each such queue will appear in its own circular array and must have its own pair of pointers, FRONT and REAR. In fact, if each queue is allocated the same amount of space, a two-dimensional array QUEUE can be used instead of the linear arrays. FRONT[K] and REAR[K] contain, respectively, the front and rear elements of row K of QUEUE, the row that maintains the queue of elements with priority number K.


My socials:
[email protected]
https://psnacademy.in
  / psnayak  
  / psnayakeducator  
https://www.buymeacoffee.com/psnayak
  / psnayak2007  

Note: This video is copyrighted, no part of it to be reproduced or republished.