Update and rename ascendingPriorityQueue.c to ascendingpriorityqueue.c

This commit is contained in:
Shubham Sah 2020-05-28 11:29:24 +05:30 committed by GitHub
parent 2bdf7732d8
commit 2a4fd0b735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,25 @@
/* Ascending priority queue using Linked List - Program to implement Ascending priority queue using Linked List */ /* Ascending priority queue using Linked List - Program to implement Ascending priority queue using Linked List */
/*A priority queue is a special type of queue in which each element is associated with a priority and is served according
to its priority. If elements with the same priority occur, they are served according to their order in the queue.
Generally, the value of the element itself is considered for assigning the priority.
For example: The element with the highest value is considered as the highest priority element. However, in other cases,
we can assume the element with the lowest value as the highest priority element. In other cases,
we can set priorities according to our needs.
In a queue, the first-in-first-out rule is implemented whereas, in a priority queue, the values are removed on the basis of priority.
The element with the highest priority is removed first.
insert() - Would insert an element in a queue
delete() - Would delete the smallest element in the queue
*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define NULL 0 #define NULL ((void*)0)
struct node struct node
{ {
@ -34,7 +51,6 @@ void insert(int x)
if(pnode==NULL) if(pnode==NULL)
{ {
printf("Memory overflow. Unable to insert.\n") ; printf("Memory overflow. Unable to insert.\n") ;
getch();
exit(1) ; exit(1) ;
} }
@ -58,7 +74,6 @@ int removes()
if(empty()) if(empty())
{ {
printf("\nQueue Underflow. Unable to remove.") ; printf("\nQueue Underflow. Unable to remove.") ;
getch() ;
exit(1) ; exit(1) ;
} }