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

Post New Answer

More C++ Code Interview Questions

how to find out the maximum number out of the three inputs.

6 Answers   ABC, Apple, C3I, HP, TCS,


hello friends, given an expression we have to remove the unwanted brackets in that expression. Eg : (a+b) ---> a+b (a+b)*(c)-----> (a+b)*c. Please mail me if you know the logic. My mail id is : saravana6m@gmail.com. Thank you in advance :-)

1 Answers   GrapeCity, Microsoft,


Perform the functionality of 2-D array through 1-D array and in it the functions to be performed were: (1) Display the array in 2-D format (2) Display a particular element (3) Display a particular row (4) Display a particular column

1 Answers   Nagarro,


Assume in University Every student in university as entity, prepare a class for student that store the roll no, name, dob of student, and make funtion of deletion, manipulation, addition of student record.

0 Answers  


How to Split Strings with Regex in Managed C++ Applications?

0 Answers   Microsoft,






output for printf("printf");

0 Answers  


What will be the output- for(i=1;i<=3;i++) { printf("%d",i); continue; i++; }

5 Answers   Impetus,


what mean void creat_object?in public class in this code class A{ public: int x; A(){ cout << endl<< "Constructor A";} ~A(){ cout << endl<< "Destructor A, x is\t"<< x;} }; void create_object(); void main() { A a; a.x=10; { A c; c.x=20; } create_object(); } void create_object() { A b; b.x=30; }

0 Answers  


how to take time as input in the format (12:02:13) from user so that controls remains between these columns?

0 Answers  


write a function – oriented program that calculates the sum of the squares from 1 to n. thus, if the input is 3, the output is 14

3 Answers  


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.

3 Answers   TCS, Vimukti Technologies, Wipro,


An array of size 5X5 is given to us. The elements from 1 to 25 are to be inserted in the array, such that starting from a particular position for an element i, the next element i+1can be inserted only at the mentioned positions (u,v), and if these all positions are occupied then it returns giving a count of how many positions have been occupied in the array: (u,v) = (x+/-3 , y) (u,v) = (x , y+/-3) (u,v) = (x+/-2 , y+/-2). Example: if the starting element is 1 with the given positions (1,2), then next element 2 can be placed at any one of the positions marked with *. _ _ _ _ _ 1 _ _ _ * _ _ _ _ _ _ _ * _ _ * _ _ _ _

0 Answers   Nagarro,


Categories