Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

Definition of priority queue was given. We have to implement
the priority queue using array of pointers with the
priorities given in the range 1..n.
The array could be accessed using the variable top. The list
corresponding to the array elements contains the items
having the priority as the array index.
Adding an item would require changing the value of top if it
has higher priority than top.
Extracting an item would require deleting the first element
from the corresponding queue.
The following class was given:
class PriorityQueue
{
int *Data[100];
int top;
public:
void put(int item, int priority); // inserts the item with
the given priority.
int get(int priority); // extract the element with the
given priority.
int count(); // returns the total elements in the priority
queue.
int isEmpty(); // check whether the priority queue is empty
or not.
};
We had to implement all these class functions.

No Answer is Posted For this Question
Be the First to Post Answer

More C++ Code Interview Questions

1+1/2!+1/3!+...+1/n!

Write an algorithm that receives a string and reverses it.

create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file

swap prog

1. Write a program using one dimensional array that calculates the sum and average of the five input values from the keyboard and prints the calculated sum and average.

Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.

write a program to sort 'n' elemnts using bubble sort

How to swap two ASCII numbers?

how to write a program that opens a file and display in reverse order?

Find the maximum product of three numbers in an array? Eg. 9,5,1,2,3 Max product= 9*5*3= 135 The array can hav negative numbers also..

write a program that calculate the volume of cylinder after user enters radius and height and show the algorithm used

How reader and writer problem was implemented and come up with effective solution for reader and writer problem in case we have n readers and 1 writer.

Categories