Question: #include #include #include Queue.h using namespace std; long k = 10; long f (long x){ return x % k; } int main() { // Declare
#include
using namespace std;
long k = 10;
long f (long x){ return x % k; }
int main() { // Declare a vector of Queue pointers vector
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#ifndef Queue_h #define Queue_h
#include
struct Link { long data; Link* next; Link(){ data = 0; next = NULL; } Link (long d){ data = d; next = NULL; } };
struct Queue { Link* front; Link* back; Queue (){ front = NULL; back = NULL; } long peek () { return front->data; } void push(long value){ if (isEmpty()){ front = new Link(value); back = front; } else { back->next = new Link(value); back = back->next; } } bool find (long value){ // Provide your code here
} bool isEmpty(){ return (front == NULL); } long pop(){ long val = front->data; Link* oldFront = front; front = front->next; delete oldFront; return val; } void print() { // Provide your code here
} ~Queue(){ // Provide your code here
} };
#endif
the Queue struct needs 3 more functions to be implemented. A find function, which tells us it a given value appears in the queue, without being destructive. A function called print, which prints out the contents of the queue, again without being destructive. Finally, there is a need for a destructor. To implement it, you can just keep popping elements off the queue until there are no elements left.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
