The Files In The Lab2 Directory Contain Classes For Two Different Type The files in the lab2 directory contain classes for two different types of doubly-linked list. The DList1 class does not use a sentinel, whereas the DList2 class does. The DList1 class is not circularly linked, but the DList2 class is (through the sentinel). Compile DList1.java and DList2.java (using "javac -g DList1.java DList2.java"). Your task is to implement two insertFront() and two removeFront() methods—one of each for each list class. insertFront() and removeFront() insert or remove an item at the beginning of a list. Make sure your implementations work for empty lists, one-node lists, and larger lists. The main() methods of DList1 and DList2 include test code, which you can run with "java DList1" and "java DList2".
Paper For Above instruction Introduction Doubly-linked lists are fundamental data structures that facilitate efficient insertion and deletion operations at both ends. This paper discusses the implementation of front insertion and removal methods for two variations of doubly-linked lists: one without a sentinel node (DList1) and one with a sentinel node (DList2). Understanding these implementations is crucial for grasping list management intricacies, especially when handling various list states such as empty, single-node, and multiple-node configurations. Implementation of insertFront() for DList1 The DList1 class, which does not utilize a sentinel node, requires careful management of pointers to maintain list integrity during front insertion. The insertFront() method creates a new node, assigns the value to it, and adjusts the pointers of the current head and the new node accordingly. The procedure accounts for the case when the list is initially empty, ensuring that the new node becomes the sole element and the head pointer is correctly assigned. For lists with existing nodes, the new node's next pointer links to the current head, and the current head's previous pointer points back to the new node, updating the head reference to the new node. Implementation of removeFront() for DList1 The removeFront() method in DList1 involves updating the head pointer to its successor and adjusting the previous pointer of this new head to null. The method must handle the scenario when the list is empty (no operation needed) and when it contains only one node (setting the head to null). By properly managing