Page 1 of 1

#include using namespace std; struct Node { }; class Queue { int data; Node *next; }; l Node "front, "rear; pu

Posted: Sat Jul 09, 2022 11:47 am
by answerhappygod
Include Iostream Using Namespace Std Struct Node Class Queue Int Data Node Next L Node Front Rear Pu 1
Include Iostream Using Namespace Std Struct Node Class Queue Int Data Node Next L Node Front Rear Pu 1 (24.39 KiB) Viewed 37 times
Include Iostream Using Namespace Std Struct Node Class Queue Int Data Node Next L Node Front Rear Pu 2
Include Iostream Using Namespace Std Struct Node Class Queue Int Data Node Next L Node Front Rear Pu 2 (41.79 KiB) Viewed 37 times
3a) Please write the segment of code for theconstructor Queue as shownin a.
[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