代写Data Structure | java代写 – Implementing Doubly Linked List

代写Data Structure | java代写 – 这是一个利用java实现双链表的基本的数据结构题目操作

LAB: Implementing Doubly Linked List

Purpose: In this assessment, you will implement a doubly linked list. We will call this Data structurea DLinkedList. We can visualize a DLinkedList as follows: Implementation: Each node (from top to bottom) of the linked list contains a value (head), a reference to the next node (tail) in the list and a reference to the predecessor (pred) node. The DLinkedList example above has 4 items in total and represents a list that currently contains the values {1, 5, 2, 12}, where the first value is 1 and the last value is 12. Task1 (5 points): Write a node class suitable for use in a DLinkedList. Each node has fields to store the references to the next and predecessor nodes, and also a field to store an int value. It should include a constructor to initialize its fields. Task2 (5 points): Write a DLinkedList class. This class should have a private field to reference the start node of the list. It should include a constructor that created an empty list. Task3 (5 points): Add the following methods to the DLinkedList class: size(): returns the size of the listi.e., the number of items in the list. add(int value): takes an int value and adds a new node representing the value to the back of the list. get(int index): takes an int value representing the index of the node and returns the current value of the node. insert(int value, int index): takes an int value and an int index of a node; inserts a new node representing the value after the node specified by the index.

remove(int index): takes an int index of a node to be removed; the node should be removed from the list. Note 1: Your code should be runnable Note 2 Plagiarism and duplication of material: The work you submit must be your own, otherwise it will be a failure.

Leave a Reply

Your email address will not be published. Required fields are marked *