Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Are based on the following Queue class code segment class QueueFull {/* Empty ex

ID: 3817770 • Letter: A

Question

Are based on the following Queue class code segment class QueueFull {/* Empty exception class */}; Class Queue Empty {/* Empty exception class */}; struct Node//Node structure int data;//Holds an integer Node* next;//Pointer to next node in the queue}; Class Queue//Linked node implementation of Queue ADT {Private: Node* front;//Pointer to front node of queue Node* rear;//pointer to last node of queue Public: Queue ()://default constructor initializes queue to be empty -Queue ();//Deallocates all nodes in the queue Void Add (int n);//Enqueues value n; if full, throws QueueFull exceprion int Remove ();//Dequeues and returns next value from the queue//If empty, throws QueueEmpty exception bool IsFull() const;//Returns true If queue is full; return false otherwise bool IsEmpty () const;//Returns true if queue is empty; return false otherwise int size () const;//Returns number of data values stored in queue}; Which if any of the following code segments correctly implements the Queue constructor? Queue:: Queue () const Queue:: Queue () {{front = NULL; front = new Node; rear = NULL; rear = new Node;}} Void Queue:: Queue () const Queue:: Queue () {{front = NULL; Front = rear; rear = NULL; count = 0;} None of the answers provided which if any of the following code segments correctly implements the IS Empty method? bool Queue:: Is empty () const bool Queue:: Is Empty () {{return (front == rear); return (count = = 0);}} bool Queue:: Is Empty () bool Queue:: IsEmpty () const {{return (rear = = NULL); return (front == NULL);}} None of the answers provided.

Explanation / Answer

Question 20 .
Answer : D
Queue:: Queue(){
front = rear;
}
Description : A the time of Queue object instantiation , front and rear node both should point to same address or null.
B option cannot be beacuase we cannot give memory at the time construction of object of class Queue because at that time now element is available, once add operation performs at that time queue gets memory space. and rest of option like A and C cannot be correct beacuse we cannot change the varaible value with const keyword.


Question 21:
----------------------
Answer : D
bool Queue::ISEmpty() const
{
return ( Front == NULL );
}

Queue works on FIFO ( First in first out ) manner, it means if first element is null that means queue is empty.

Please let me know, if you face any dificullties while making understanding on below concept.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote