Question: C++ Code! These are the numbers in the txt file: 1 10 7 23 9 3 12 5 2 32 6 42 This is the

C++ Code!

C++ Code! These are the numbers in the txt file: 1 10

These are the numbers in the txt file: 1 10 7 23 9 3 12 5 2 32 6 42

This is the .h file template given:

#ifndef PRIORITY_QUEUE_H

#define PRIORITY_QUEUE_H

#include

using namespace std;

/**

* Note: in order to try to make things easier, the queue below will only have a single type of value

* in it instead of a (key, value) pair. You could still store a (key, value) pair, but you would

* make a priority queue that stored an object with both the key/value in it and a comparison operator

* that only compared the keys.

*/

template

class PriorityQueue

{

private:

// data here

public:

PriorityQueue(void);

~PriorityQueue(void);

bool isEmpty(void);

int size(void);

// inserts a piece of data into the priority queue

void insertItem ( Type data );

// removes and returns the minimum value in the queue

// throws an exception if the queue is empty

Type removeMin ( void );

// return the minimum value in the queue without removing it

// throws an exception if the queue is empty

Type minValue ( void );

};

#endif

For this programming assignment, you will implement a Priority Queue. Your Priority Queue can grow dynamically as in the Stack assignment (although you should use a method with amortized cost Q(1) for insertion) or you may make a Priority Queue large enough to fit all of your data ahead of time. You will build three different implementations of the Priority Queue. Two of these implementations will be based on a List. The first list implementation, UnsortedPQ should use an unsorted list to store the data. The second list implementation, SortedPQ, should use a sorted list. The third implementation, HeapPQ. should be an array-based implementation of a Heap We will test your implementations using a set of numbers in a text file named "numbers.txt". Each line of the file will contain a number. The first number will be which Priority Queue to use (0=Unsorted' 1 =SortedPQ, 2=Heape ). The second number will be the number of remaining elements in the file. n The first two numbers of the file (queue type and n) will NOT be inserted into your Priority Queue However, the remaining n numbers will be inserted. You should then remove all n numbers and print them to the screen. Here is an example numbers.txt file Using your three implementations, you will also time how long it takes to insert n random numbers and the total time to insert n random numbers and remove n random numbers. You may use a random number generating as opposed to the file input above. Time how long insertion takes using the StopWatch class we provided. You should measure the total time at fixed intervals. You will then show a graph of the total insertion time versus the number of items inserted for each implementation. You will then time how long insertion and removal takes by inserting n numbers and removing n numbers for each implementation. You will then graph the sorting time versus the number of elements. This process will allow you to see how your choice of implementation can affect performance Coding Portion (50 Points) Start with the following template: PriorityQueue.h, and create three versions of the Priority Queue (using templates for the type of object) filling in all of the member functions Be sure to test the correctness of your algorithms and implementations (we will) Your code will be graded based on whether ornot it compiles, runs, produces the expected output, produces correct output, whether or not your experimental setup is correct, and your coding style (does the code follow proper indentation/style and comments) For this programming assignment, you will implement a Priority Queue. Your Priority Queue can grow dynamically as in the Stack assignment (although you should use a method with amortized cost Q(1) for insertion) or you may make a Priority Queue large enough to fit all of your data ahead of time. You will build three different implementations of the Priority Queue. Two of these implementations will be based on a List. The first list implementation, UnsortedPQ should use an unsorted list to store the data. The second list implementation, SortedPQ, should use a sorted list. The third implementation, HeapPQ. should be an array-based implementation of a Heap We will test your implementations using a set of numbers in a text file named "numbers.txt". Each line of the file will contain a number. The first number will be which Priority Queue to use (0=Unsorted' 1 =SortedPQ, 2=Heape ). The second number will be the number of remaining elements in the file. n The first two numbers of the file (queue type and n) will NOT be inserted into your Priority Queue However, the remaining n numbers will be inserted. You should then remove all n numbers and print them to the screen. Here is an example numbers.txt file Using your three implementations, you will also time how long it takes to insert n random numbers and the total time to insert n random numbers and remove n random numbers. You may use a random number generating as opposed to the file input above. Time how long insertion takes using the StopWatch class we provided. You should measure the total time at fixed intervals. You will then show a graph of the total insertion time versus the number of items inserted for each implementation. You will then time how long insertion and removal takes by inserting n numbers and removing n numbers for each implementation. You will then graph the sorting time versus the number of elements. This process will allow you to see how your choice of implementation can affect performance Coding Portion (50 Points) Start with the following template: PriorityQueue.h, and create three versions of the Priority Queue (using templates for the type of object) filling in all of the member functions Be sure to test the correctness of your algorithms and implementations (we will) Your code will be graded based on whether ornot it compiles, runs, produces the expected output, produces correct output, whether or not your experimental setup is correct, and your coding style (does the code follow proper indentation/style and comments)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!