Question: CSE2251. - Data Structures and Algorithms Lab Lab 14 Priority Queue In today's lab we will design and implement the Priority Queue ADT. heaptype, #ifndef

 CSE2251. - Data Structures and Algorithms Lab Lab 14 Priority QueueIn today's lab we will design and implement the Priority Queue ADT.heaptype, #ifndef HEAPTYPE_H_INCLUDED #define HEAPTYPE__INCLUDED template struct Heaplype patype.h #ifndef PQTYPE_H_INCLUDED #define

CSE2251. - Data Structures and Algorithms Lab Lab 14 Priority Queue In today's lab we will design and implement the Priority Queue ADT. heaptype, #ifndef HEAPTYPE_H_INCLUDED #define HEAPTYPE__INCLUDED template struct Heaplype patype.h #ifndef PQTYPE_H_INCLUDED #define POTYPE_H_INCLUDED #include "heaptype.h" #include "heaptype.cpp" class Full PQ U; class Empty po U; template class Pype void Reheap Down(int root, int bottom); void Reheapup(int root, int bottom; Item Type* elements; int numElements; 1: #endif // HEAPTYPE_H_INCLUDED heaptype. Opp #include "heaptype.h" template void Swap (ItemType& one, ItemType & twal ItemType temp; temp - one; - cne = two; two - tempi } 1 template void HeapType:: ReheapDown{int root, int bottom) int maxChild; int rightChild; int leftchild; public: POType (int); POType(): vaid MakeEmpty(); bool IsEmpty(); bool Is Full(); vaid Enqueue (ItemType); void Dequeue (ItemType); private: int length; HeapType items; int maxTtems; ; #endif // POTYPE_E_INCLUDED patype.cpp #include "patype.h" template FOType:: POType (int max) left Child = root*2 +1; = 1 rightChild - root.2-2; if (leftchild - bottom) 1 if (leftchild - bottom) maxchild - leftchild; else 1 if (elements (leftchild} FOType: :-PQType 1 { delete Il items. elements; } template class ItemType> void PQType: : MakeEmpty ) Swap (elements [rootl, elements [rraxchild]); Reheap Down (maxchild, bettem); length = 0; 1 template bool FQType :: IsEmpty 1 template void HeapType:: ReheapUp (int root, int bottom) return length -- 0; } template bool POType:: Is Full() int parent; if (bottom > root) return length == maxItems; ! parent = (bottom-1) / 2; if (elements [parent] { Swap (elements [parent], elements [bottom]); ReheapUp (root, parent); 1 template void POTypeItemType> : : Enqueue (ItemType newItem) template vaid POType:: De queue (ItemTypes item) { if (length = 0) throw Empty(); else if (length == maxItems) throw Full PC() else 1 length; items. elements[length-1] = newItem; items, Reheapup(0, length-1); item-items.elements [0]; items.elements [0] = items.elements[length-1]; length- items. ReheapDown (0, length-1); 1 Now generate the Driver file (main.cpp) where you perform the following tasks: Expected Output . Queue is empty . Queue is not empty 17 . 11 Operation to Be Tested and Description of Action Input Values Create a PQType object with size 15 Print if the queue is empty or not Insert ten items, in the order they appear , 14 9 2 7 3 11 17 051 Print if the queue is empty or not Dequeue one element and print the dequeued value Dequeue one element and print the dequeued value You have N magical bags of candies in front of you. The 5 3 2 1 7 4 2 bag has A candies in it. It takes you one minute to finish a bag of candies, no matter how many candies in it. Every time you finish a bag with X candies in it, the bag is magically replenished with X/2 (rounded down to the nearest integer) more candies. Write a program that determines the maximum number of candies you can eat in k minutes. . 14 The input is a sequence of integers. The first integer N is the number of bags. The next integer K is the number of minutes you have. The next Nintegers is the number of candies in the bags. The output of your program is a single integer which represents the maximum number of candies you can eat. Description Lab14.pdf Referring to the Lab Manual(Priority Queue using Heap) as I discussed in the class that in this bonus assignment you need to find if there any mistake in source codes. It is preferred that your answer will contain three parts: 1. Identification of mistake/error(it can be any type of error or problem which may result in incorrect result) 2. Explain why it is an error or a problem 3. Correct the problem or give an alternative solution Submission: You can use either paper(hardcopy) or document file(softcopy) or both for your answer as you deem necessary Submit Assignment

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!