Question: I have this Java code to delete the last element in a circular double linked list. I need help writing a method that delete the
I have this Java code to delete the last element in a circular double linked list. I need help writing a method that delete the first element, and a method that delete an element at a given position
////////////////////////////////////////////////////
public class CDLinkedList
private static class Node
private Node
public void deleteLast(){ if (size == 0) { System.out.println("Empty list"); return; } else if (size==1) { last = first; first= null; return; } last.prev.setnext(first); first.setprev(last.prev); last= last.prev; size--;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
