Language: C++ (Please include simple explanation & Screenshot of the output)
Implement a Priority Queue with a Binary HEAP. Use a Max Heap.
Create a class called Node: Have a Name and Priority.
Data set - 10 is the highest priority, 1 is lowest priority.
Enqueue and dequeue in the following order.
Function Name, Priority
Enqueue Joe, 3
Enqueue Fred, 1
Enqueue Tuyet, 9
Enqueue Jose, 6
Dequeue
Enqueue Jing, 2
Enqueue Xi, 5
Enqueue Moe, 3
Dequeue
Enqueue Miko, 7
Enqueue Vlady, 8
Enqueue Frank, 9
Enqueue Anny, 3
Dequeue
Enqueue Xi, 2
Enqueue Wali, 2
Enqueue xChe, 6
Enqueue xVerra, 8
Dequeue
Dequeue
Dequeue
Dequeue
Dequeue
Dequeue
Dequeue
Dequeue
Dequeue
Dequeue
Dequeue
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
struct node
{
int priority;
int content;
struct node *connect;
};
class Priority_Queue
{
private:
node *top;
public:
Priority_Queue()
{
top = NULL;
}
void insert(int value, int priority)
{
node read, q;
read = new node;
read->content = value;
read->priority = priority;
if (top == NULL || priority < top->priority)
{
read->connect = top;
top = read;
}
else
{
q = top;
while (q->connect != NULL && q->connect->priority
<= priority)
q=q->connect;
read->connect = q->connect;
q->connect = read;
}
}
void del()
{
node *read;
if(top == NULL)
cout<<"Queue Underflow\n";
else
{
read = top;
cout<<"Deleted value is:
"<<read->content<<endl;
top = top->connect;
free(read);
}
}
void display()
{
node *input;
input = top;
if (top == NULL)
cout<<"Queue is empty\n";
else
{ cout<<"Queue is :\n";
cout<<"Priority value\n";
while(input != NULL)
{
cout<<input->priority<<"
"<<input->content<<endl;
input = input->connect;
}
}
}
};
int main()
{
int option, value, priority;
Priority_Queue pq;
do
{
cout<<"1.Insert\n";
cout<<"2.Delete\n";
cout<<"3.Display\n";
cout<<"4.Quit\n";
cout<<"Enter your option : ";
cin>>option;
switch(option)
{
case 1:
cout<<"Input the value value to be added in the queue :
";
cin>>value;
cout<<"Enter its priority : ";
cin>>priority;
pq.insert(value, priority);
break;
case 2:
pq.del();
break;
case 3:
pq.display();
break;
case 4:
break;
default :
cout<<"Wrong option\n";
}
}
while(option != 4);
return 0;
}

Language: C++ (Please include simple explanation & Screenshot of the output) Implement a Prio...
Language C++ (Please include a short description & Screenshot of output) 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 the code below. #include <iostream> void quickSort(int a[ ], int first, int last); int pivot(int a[], int first, int last); void swap(int& a, int& b); void swapNoTemp(int& a, int& b); void print(int array[], const int& N); using namespace std; int main() { int test[]...
(Data Strcture)
Tool(s)/Software Java programming language with NetBeans IDE. Description Implementing a Linear Queue using a Singly Linked-List and Implementing a Priority Queue Tasks/Assignments(s) ■ Write your own program to implement priority queue using the Linked-List and implement the Enqueue, Dequeue and Display methods. implement the Merge methods in your main program that receive Q1 and Q2 and merge the two queues into one queue. Public static PriorityQueue MergeQueue(PriorityQueue Q1,PriorityQueue Q2) Write main program to test priority queue class and...
in C++ please
1- Write the priority queue code – include insertion and remove operations. Given the following values – test your program. Use max-heap. 8, 17, 4, 99, 3, 6, 88, 34, 65 2- Sort the numbers: 8, 17, 4, 99, 3, 6, 88, 34, 65 using heap-sort and show the steps - you may write it on a paper and take a picture and include it here. Show all steps. 3- Write the heap-sort code and test the...
Using C++, data structures, C++ STL, inputs and expected
outputs are shown below.
Max Heap Heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either > (in a max heap) or s (in a min heap) the key of C. The node at the "top" of the heap (with no parents) is called the root node. In binary-tree based heap, it...
In def c++ IDE correct mistake and screenshot output ------------------------------------------------------------------------------ #define NULL 0 #include <iostream> /* Name: Rabia Saad Al-wethnani ID: 43503535 Section: 2486 */ using namespace std; struct Node { int item; //data Node *next; //pointer to the next node in the list }; Node* createNode(int); int isPresent(Node*, int); void appendNode(Node*&, int); void displayList(Node*); void printLists(Node*, Node*); void swapNodes(Node* &head, int s); void findIntersection(Node* first, Node* P); void findUnion(Node* first, Node* P); int main() { Node* L = NULL,...
Radix sort C++ Come up with an unsorted array of numbers (integer array). Sort the numbers in ascending order and descending order and display them using radix sort. First sort in ascending, then reset the array to its original order and finally sort the array again in descending order. USE THIS STUCTURE struct nodeQ{ node *front; node *rear; }; nodeQ que[10]; enqueue(que[i],data); EXAMPLE: Original, unsorted list: [170, 45, 75, 90, 2, 802, 24, 66] 1ST PASS:...
***** running late, mere 3 hours left for due time, please help ** #needed in c++ #inputfile MinPath2.txt 0 SF 1 LA 2 DALLAS 3 CONCORD 4 PHOENIX 5 CHICAGO 6 ST LOUIS 7 BOSTON 8 NY 9 LONDON 10 PARIS 11 TOKYO 12 BANGKOK 13 MEXICO CITY 14 MONTREAL -1 0 1 40 0 2 100 0 4 130 0 8 200 0 9 800 0 10 900 1 2 50 1 3 80 1 4 70 1 8 ...
I've posted 3 classes after the instruction that were given at start You will implement and test a PriorityQueue class, where the items of the priority queue are stored on a linked list. The material from Ch1 ~ 8 of the textbook can help you tremendously. You can get a lot of good information about implementing this assignment from chapter 8. There are couple notes about this assignment. 1. Using structure Node with a pointer point to Node structure to...
I NEED HELP WITH THIS HOMEWORK!!!! What is a characteristic of a bag data type? Elements are added and removed in any order Elements are removed in the same order they were added Distinct elements are added in any order but are removed beginning with the last one added Distinct elements are removed in the reverse order they were added Which scenario illustrates a data stack structure Standing in a line to be serviced Filing documents in alphabetical order Offering...
C language huffman
This exercise will familiarize you with linked lists, which you will need for a subsequent programming Getting Started assignment Overview Requirements Getting Started Submit Start by getting the files. Type 264get hw13 and then cd hw13 from bash. Pre-tester You will get the following files: Q&A Updates 1. huffman.h: An empty header file, you have to define your own functions in this homework. 2. huffman.c: An empty c file, you have to define your own functions in...