Question
The removeFirst method of the SinglyLinkedList class includes a special case to reset the tail field to null when deleting the last node of a
The removeFirst method of the SinglyLinkedList class includes a special case to reset the tail field to null when deleting the last node of a list (see lines 51 and 52 of Code Fragment 3.15). What are the consequences if we were to remove those two lines from the code? Explain why the class would or would not work with such a modification.
MAINLY:
Be specific, what happens when we try to add a node after weve removed the last node? What if we then try to immediately remove the node we just added? Specifically say what happens to the tail pointer after we use removeFirst() to remove the last element of a list. Then what happens to tail if we addFirst()? What if we addLast()?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started