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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
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

Post 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 35 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 35 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply