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

swap prog

3 Answers   TCS,


can you please write a program for deadlock that can detect deadlock and to prevent deadlock.

0 Answers  


write a program to perform generic sort in arrays?

0 Answers  


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

0 Answers  


program to find the magic square using array

1 Answers  






Code for Two Classes for Doing Gzip in Memory?

0 Answers  


Write a simple encryption program using string function which apply the substitution method.

0 Answers  


how to diplay a external image of output on winxp by using c & c++,

0 Answers  


Algorithm in O(2n) Presently we can solve in our hypothetical machine problem instances of size 100 in 1 minute using algorithm A, which is a O(2n). We would like to solve instances of size 200 in 1 minute using algorithm A on a new machine. What is the speed of the new machine should be?

2 Answers   ABC, Qatar University,


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

0 Answers  


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  


1. Write a program that performs the following. The user inputs a number and then enters a series of numbers from 1 to that number. Your program should determine which number (or numbers) is missing or duplicated in the series, if any. For example, if the user entered 5 as the initial number and then entered the following sequences, the results should be as shown. Input Sequence Output ---------------------- --------------- 1 2 3 4 5 Nothing bad However, if 7 were the high number, the user would see the results on the right for the following number entries: Input Sequence Output ---------------------- --------------- 1 3 2 4 5 Missing 6 Missing 7 And if 10 were the high number and the user entered the numbers shown on the left, note the list of missing and duplicate numbers: Input Sequence Output ---------------------- --------------- 1 2 4 7 4 4 5 10 8 2 6 Duplicate 2 ( 2 times) Missing 3 Duplicate 4 ( 3 times ) Missing 9

1 Answers  


Categories