l The class below defines an ADT of singled linked lists. Using this class inter
ID: 3841230 • Letter: L
Question
l The class below defines an ADT of singled linked lists. Using this class interface to answer all the questions. When you are implementing a function, please assume separate compilation. o13 points) MFile: linked List ha include intreamo suing namespace dass public: Default constructor List(const Lisak aListol Copy constructor Destructor Liit operatoruroconst List & rhs): Ulassignment operator bool isEmpyo const: Ireturm true if the List object is empty int gets engdho const: Uneturn the length of the List object //insert a new node to the front of the list. The data member of this new node is newltem. void insert front const int newltem): Iremove the last side from the List void remove last): check whether a node containing dataltem exists on the List. bool retiever int tem const; member of each node J010overload the operator to print the data Hon the list in the same order as they appear on the list. (1 pnt) struct Node int item: A data itern on the list Node next: Pointer to the next node. inr size: Number of items in list. Node "headul Pointer to linked list of items. fend List your answer right below Q1. "Have you answered Q1 above? Please write down linkedlist.cpp Note that (1) your answers to e4 below are included in a separate file called allocate memory (2 you' ll need exception handling when calling the new operator toExplanation / Answer
1. Since we already have length function in the implementation we can use it to write isempty method.
bool isEmpty() const
{
if(this.getLength()==0)
return true;
else
return false;
}
2.This will be called when we write delete List;
3.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.