And just like queue you can also implement manually.
6.13 Deletion in priority Queue
To delete we just simple delete like the previous time,
T pop() {
if (front == -1) {
cout << "UNDERFLOW!\n";
return (T)0;
}
T item = arr[front];
if (front == rear)
front = -1, rear = -1;
else if (front == MAX_NUM - 1)
front = 0;
else
front++;
return item;
}
6.14 Insertion in priority queue
And for insertion, we can go ahead and implement a one way list.
And if you want, you can also try something similar that we did in queue. In this case, we will try to use our free spaces, left in the memory!