QuestionQuestion

Program 1 – Implement a Priority Queue(PQ) using an UNSORTED LIST. Use an array size of 10 elements. Use a circular array: Next index after last index is 0. Add the new node to next available index in the array. When you add an element, add 1 to index (hit max index, go to index 0). Test if array in full before you add. When you remove an element, from the list, move the following elements to the left to fill in the blank, etc ( Like prior program done with LISTS )
Program 2 – Implement a Priority queue using a SORTED list. Use Quick sort after adding a new node. Example of quick sort below. Adopt to your program.
Program 3 – Implement a Priority Queue with a Binary HEAP. Use a Max Heap.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

Documentation
Priority queue implementation

A propriety queue is an abstract data type, in which each element has a priority assigned. The elements from the priority queue are served according to their priority: an element with a higher priority is served (removed when requested) earlier than an element with a lower priority.
The operations that make sense for a priority queue are:
• peek – return the element with the highest priority
• pop – remove the element with the highest priority from the queue
• insert – inserts an element into the data structure

For this assignment there were 3 implementations required. They are compared in the table below, see the next pages for the explanation of these complexities.


#include "priorityqueuecirculararray.h"

#include <limits>
#include <iostream>
using namespace std;


// utility method that gets the INDEX of the maximum value from the circular buffer array
// arraySize - the size of the array
// startIndex - the index to the start of the circular array
// endIndex - the index to the end of the circular array
int getMax(double array[], int arraySize, int startIndex, int endIndex);


PriorityListCircularArray::PriorityListCircularArray()
{
    m_startIndex = 0;
    m_endIndex = ARRAY_CAPACITY - 1;
    m_numElements = 0;
    // init all the elements to 0
    for(int i = 0; i < ARRAY_CAPACITY; i++)
       m_array[i] = 0;
}

PriorityListCircularArray::~PriorityListCircularArray()
{
    m_startIndex = 0;
    m_endIndex = ARRAY_CAPACITY - 1;
}

double PriorityListCircularArray::peek()
{
    // we call the utility method to get the position of the maximum element from the array...

By purchasing this solution you'll be able to access the following files:
Solution.docx and Solution.zip.

$30.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats