if we have following List classes: public class LinkedList<T> { class ListNode {
ID: 3718866 • Letter: I
Question
if we have following List classes:
public class LinkedList<T> {
class ListNode {
protected T value;
protected ListNode next;
public ListNode(T val, ListNode nxt) {
value = val;
next = nxt;
}
public ListNode(T val) {
this(val, null);
}
public ListNode() {
this(null, null);
}
}
can you write the folowing methods in java:
1. Write a method for the LinkedList class called boolean removeLast(T val) which removes the last occurrence of val from the list. The method should return true if it is successful.
2. Repeat the previous problem using a doubly linked list.
Explanation / Answer
Please find my answer for Q1.
Please repost Q2.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.