#include using namespace std; struct Node { }; class Queue { int data; Node *next; }; l Node "front, "rear; pu
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
#include using namespace std; struct Node { }; class Queue { int data; Node *next; }; l Node "front, "rear; pu
[2 Marks]
3b) Please complete the segment of code forthe Enqueue function asshown in b.
[2 Marks]
3c) Please complete the segment of code forthe Dequeue function asshown in c.
[3 Marks]
3d) Please complete the code segment as showin d.
#include<iostream> using namespace std; struct Node { }; class Queue { int data; Node *next; }; l Node "front, "rear; public: Queue() _(a)__// number of line(s) is not an indication of answer }; void Enqueue(int elem); void Dequeue(): void display(); void Queue::Enqueue(int elem) // insertion values from rear side { Node *new_node; new_node = new Node; new_node->data - elem; new_node->next = NULL; if(front == NULL) { } } { front-new_node; rear-new_node; else } (b)___// number of line(s) is not an indication of answer 8
xaid Queue: Dequeue delete values from front side { Node *temp: if(front == NULL) { sout<<"Queue is Empty": } slas ( _(c)_______// number of line(s) is not an indication of answer xaid Queue::display( { Node *temp: temp-front; while(temp!=NULL) sauttemp->data" " tem=temp->next; } cout<<endl; int main() (d)_____// number of line(s) is not an indication of answer data. Enqueue (1); Sut<<"Queue after inserting the 1st values is :"<<endl; data.display(); data.Enqueue(2); saut<<"Queue after inserting the 2nd value is :"<<endl; data.displayi): data.Enqueue (3); Sout<<"Queue after inserting the 2nd value is :"<<endl; data.display: data.Dequeue: Saut<<"Queue after deleting a value from the queue:"<<endl; data.display: CJ