Queue is a basic data structure that holds a list of items and accesses them fol
ID: 3790328 • Letter: Q
Question
Queue is a basic data structure that holds a list of items and accesses them following the first-in first-out (FIFO) policy. The ADT queue defines the following functions: void enqueue(int item);//append a new item into the queue int dequeue ();//get the first item from the queue, and delete it from the queue int size ();//get the current number of items inside the queue int front ();//get the first item from the queue without deleting it bool is Empty ();//return true if the queue is empty, or return false void print ();//display all items in the queue from the beginning to the end on screen You need to implement all of the above functions in a defined queue class (prototype is provided by the instructor). Please download three files (main.cpp, queue.cpp, queue. h) from courses, and complete them using C++. You need to implement the queue ADT functions in queue.cpp file, and test them in main.cpp. submission policy: need to submit your completed program to courses by 02/13/2017 You need to upload all of your source code: main cpp, queue cpp, and queue. h. Do NOT change any of their names or upload other files to e courses. Please note that failure to follow the submission rule will NOT receive credit for the homework. Late submission will receive 20percentage penalty per day.Explanation / Answer
#include #include #define MAX_SIZE 10 using namespace std; class Queue{ private: int item[MAX_SIZE]; int rear; int front; public: Queue(); void enqueue(int); int dequeue(); int size(); void print(); bool isEmpty(); bool isFull(); }; Queue::Queue(){ rear = -1; front = 0; } void Queue::enqueue(int data){ item[++rear] = data; } int Queue::dequeue(){ return item[front++]; } void Queue::print(){ if(!this->isEmpty()){ for(int i=front; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.