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
can you please write a program for deadlock that can detect deadlock and to prevent deadlock.
write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.
1+1/2!+1/3!+...+1/n!
#include<iostream.h> //main() //{ class A { friend class B; public: void read(); }; class B { public : int a,b; }; void A::read() { cout<<"welcome"; } main() { A x; B y; y.read(); } In the above program......, as B is a friend of A B can have access to all members,i cant access y.read . could you please tell me the reason and what would i code to execute this program?
write a program that accepts a number and outputs its equivalent in words. take note that the maximum input is 3000
Coin Problem You are given 9 gold coins that look identical. One is counterfeit and weighs a bit greater than the others, but the difference is very small that only a balance scale can tell it from the real one. You have a balance scale that costs 25 USD per weighing. Give an algorithm that finds the counterfeit coin with as little weighting as possible. Of primary importance is that your algorithm is correct; of secondary importance is that your algorithm truly uses the minimum number of weightings possible. HINT: THE BEST ALGORITHM USES ONLY 2 WEIGHINGS!!!
1 Answers Motorola, Qatar University,
write a c program, using for loop, that accepts and odds two numbers. The output must be the sum and the addens. This should be repeated 5 times while the first number is decremented by one and the second number is incremented by 1.
how to diplay a external image of output on winxp by using c & c++,
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.
Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?
Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.
0 Answers Facebook, Webyog, Wipro,
develop a program to calculate and print body mass index for 200 employees
0 Answers Jomo Kenyatta University,