Question: This question is in regards to singly linked lists. What are the consequences if we were to remove lines 51 and 52 from the code?
This question is in regards to singly linked lists. What are the consequences if we were to remove lines 51 and 52 from the code? Explain why the class would or would not work with such a modification.
46 public E removeFirst( ) { // removes and returns the first element
47 if (isEmpty( )) return null; // nothing to remove
48 E answer = head.getElement( );
49 head = head.getNext( ); // will become null if list had only one node
50 size;
51 if (size == 0)
52 tail = null; // special case as list is now empty
53 return answer;
54 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
