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

Data Structure代写 | java代写 – 这是一个利用java进行双链表的代写任务

Assignment

Implementing Doubly Linked List

Purpose: In this assessment, you will implement a doubly linked list. We will call this Data structure a 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.

发表评论

电子邮件地址不会被公开。 必填项已用*标注