5. Implementing Priority Queue using Linked List in C | PSN Academy

Опубликовано: 16 Март 2026
на канале: PSN Academy
2,424
55

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.

This algorithm deletes and processes the first element in a priority queue which appears in memory as a one-way list.
1.Set ITEM : = INFO[START]. [This saves the data in the first node.]
2. Delete first node from the list.
3. Process ITEM.
4. Exit.

This algorithm adds an ITEM with priority number N to a priority queue which is maintained in memory as a one-way list.
(a) Traverse the one-way list Until finding a node X whose priority number exceeds N. Insert ITEM in front of node X.
(b) If no such node is found, insert ITEM as the last element of the list.


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.

Thumbnail background image: http://www.freepik.com | Designed by pch.vector / Freepik

#priorityqueue #queue #queues #array #linkedlist #priority #psnacademy