Note that this is a circular list Consider a pointerbased im
Note that this is a circular list.
Consider a pointer-based implementation for ADT queue (similar to the one from lecture) that uses a circular list, but no front pointer. (You can get to the front by going to the element after the back, unless the list is empty.) Write the enqueue member operation. The prototype (following the queue class from lecture) is: template bool Queue::enqueue(Queueltem newltem);Solution
Hi Friend, You have not posted the structure od Queue and Node class.
I have implemented ypu just change some variable name according to your class declaration.
template<class QueueItem>
 bool Queue<QueueItem>::enqueue(QueueItem newItem){
   
    // we have \'back\' pointer that points to last element of circular linked list
    // since we add element in queue at last so,
Node *newNode = new Node(newItem);
   if(back == NULL){
        back = newNode;
        back->next = back; // one element in circulat list
    }else{
        newNode->next = back->next; // newNode points to first element of list
        back->next = newNode; // back points to newNode
        back = newNode; // now newNode becomes last element
    }
 }

