2. (30 pts) Given the single-linked list below, assume that the variable tail re
ID: 3872900 • Letter: 2
Question
2. (30 pts) Given the single-linked list below, assume that the variable tail references the last Node SingleLinkedList Node Node Node Node head next data = next data = next = data next null data = String Strin String String value "Tom" value "Dick" value"Harry" value "Sam" Write the code to do each of the following operations. Assume that the result of each operation does not affect the other operations. In another word, assume that each operation always starts with the linked list in the figure above. Also assume that your code are inside a method in the class SingleLinkedList and have direct access to data field head. You are allowed to call other methods in the class SingleLinked List given in Lec#7 and Lec#8 a. Insert "Bill" before "Tom" b. Insert "Sue" before "Sam" c. Remove "Tom" d. Remove “Sam",Explanation / Answer
I have coded SingleLinkedList class. It has 2 methods which are useful to complete these 4 tasks.
methods:
insertBefore()
remove()
You can use insertBefore() to complete tasks a) & b)
You can use remove() to complete tasks c) & d)
SingleLinkedList.java
Node.java
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.