Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are multiple pictures 2 5 Programming (30 points) Write your Java Class named LinkedListYourName as follows. Choose one of the given files (LinkedListGGGG.java or

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
There are multiple pictures
2 5 Programming (30 points) Write your Java Class named LinkedListYourName as follows. Choose one of the given files (LinkedListGGGG.java or LinkedListo000.java) LinkedListGGGG.java is a LinkedList Class with Generic LinkedListo000.java is a LinkedList Class with Object element type Change the filename and Class name with yours LinkedlistYourName Implement all class methods. add, addFirst, addLast, getFirst, getLast, remove, removeFirst, removeLast You cannot change the name of methods, parameter type, return type. Remove all written comments from the code, then write your comments. 1 // Student Information here 2 3 // Linkedlist with Generic 4 // Change ALL the CLASSNAME and FILENAME with your name 5 // ex) LinkedlistGGGG -> LinkedListLee 6 // ex) LinkedlistGGGG-java -> LinkedListlee.java 7 08 public class LinkedList Your Name { private Node head = null; 10 private Node tail = null; 11 12 // Because LinkedList and Node use same element type , 13 // I don't need to use another generic for internal Node Class (I used it in our class, but not now) 14 public class Node { 15 E data; 16 Node next; 17 7/Node constructor 18 public Node(E element) { 19 data = element; 20 next = null; 21 22 //Node toString method to print Node element 23 public String toString() { 24 return String.valueof(this.data); 25 } 26 ) 27 28 public void add(int index, E element) { 29 Node temp1 - head; 30 while(-- index > 0) 31 temp1 - templ.next; 32 33 // Write your code here! // 34 IMITI 35 // add an element(as a node) at given index 36 37 38 public void addFirst(E element) { 39 40 // Write your code here! // 41 17/ 42 // add an element(as a node) at the first of the list 43 public void addlast(E element) { 1/17 // Write your code here! // WA TIMIT // add an element(as a node) at the last of current list 44- 45 46 47 48 49 50- 51 52 53 54 public E getFirst() { // Write your code here! // 55 V/ Return the element value of first node 3 public E getLast() { 1177/17 // Write your code here! // ///////////// // Return the element value of first node public void remove(int index) { IIIIIIIII // Write your code here! // // Remove an element(a node) at given index } 56e 57 58 59 6e 61 62e 63 64 65 66 67 68 699 70 71 72 73 74 75 76 77e 78 79 80 81 82 83 84 85- 86 public E removeFirst() { ////// TTTTTT // Write your code here! // ///// // Return the element value of first node // Remove an element (a node) at given index } public E removelast() { ///// // Write your code here! // TIT // Return the element value of first node // Remove an element(a node) at given index 3 public int size() { 85e 86 87 88 89 90 91 92 public int size() { 1/ // Write your code here! // TIITTITTTTTTTTTTTTTTTTTTT V/ Return how many elements in current list // Don't keep the size value, when size() method called, // retrieve whole list and count the number of element and return it } 93 940 95 96 97 98 99 100 101 102 103 104 105 106) public String toString() { Node temp = head; String str = while(temp.next != null) { str str + temp.data + ", "; temp temp.next; } str str + temp.data; return str + "]"; 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

What is human nature?

Answered: 1 week ago