Data Structure & Algorithum java program Do the following: 1) Add a constructor to the class "LList" that creates a list from a given array of objects. 2) Add a method "addAll" to the "LList" class that adds an array of items to the end of the list. The header of the method is as follows, where "T" is the generic type of the objects in the list.
Data Structure & Algorithum java program Do the following: 1) Add a constructor to the class "LList" that creates a list from a given array of objects. 2) Add a method "addAll" to the "LList" class that adds an array of items to the end of the list. The header of the method is as follows, where "T" is the generic type of the objects in the list.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Data Structure & Algorithum java program
Do the following:
1) Add a constructor to the class "LList" that creates a list from a given array of objects.
2) Add a method "addAll" to the "LList" class that adds an array of items to the end of the list. The header of the method is as follows, where "T" is the generic type of the objects in the list.
3) Write a Test/Driver program that thoroughly tests all the methods in the class "LList".
![number0fEntries++;
} else {
throw new Index0ut0fBoundsException ("Illegal position given.");
48
49
50
51
}
52
53
54
550
A 56
@0verride
public T remove (int givenPosition) {
T result = null;
if((givenPosition >= 1) && (givenPosition <= number0fEntries)) {
57
58
if(givenPosition == 1) {
result =
firstNode = firstNode.getNextNode();
}else
Node<T> nodeBefore =
Node<T> nodeToRemove = nodeBefore.getNextNode();
Node<T> nodeAfter
result = nodeToRemove.getData();
nodeBefore.setNextNode(nodeAfter);
59
60
61
firstNode.getData();
62
63
64
getNodeAt (givenPosition - 1);
65
66
nodeToRemove.getNextNode();
67
68
69
number0fEntries++;
return result;
} else {
throw new IndexOut0fBoundsException ("Illegal position given.");
70
71
72
73
74
}
75
7660
A 77
@Override
public void clear() {
whlutlllAuto-aenerated method stub
I.
78
79
80
81
82e
A 83
84
85
@Override
public T replace(int givenPosition, T newEntry) {
if((givenPosition >= 1) && (givenPosition <= number0fEntries)) {
Node<T> desiredNode =
T originalEntry = desiredNode.getData();
desiredNode.setData(newEntry);
return originalEntry;
} else {
throw new IndexOut0fBoundsException ("Illegal position given");
getNodeAt (givenPosition);
86
87
88
89
%3D
90
01
Problems
@Javadoc Declaration
Console X
No consoles to display at this time.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdad5a646-4583-4c4b-beba-29e57d936914%2F00d51255-5847-46c8-923c-8525e793d9bd%2Fjd1klgr_processed.jpeg&w=3840&q=75)
Transcribed Image Text:number0fEntries++;
} else {
throw new Index0ut0fBoundsException ("Illegal position given.");
48
49
50
51
}
52
53
54
550
A 56
@0verride
public T remove (int givenPosition) {
T result = null;
if((givenPosition >= 1) && (givenPosition <= number0fEntries)) {
57
58
if(givenPosition == 1) {
result =
firstNode = firstNode.getNextNode();
}else
Node<T> nodeBefore =
Node<T> nodeToRemove = nodeBefore.getNextNode();
Node<T> nodeAfter
result = nodeToRemove.getData();
nodeBefore.setNextNode(nodeAfter);
59
60
61
firstNode.getData();
62
63
64
getNodeAt (givenPosition - 1);
65
66
nodeToRemove.getNextNode();
67
68
69
number0fEntries++;
return result;
} else {
throw new IndexOut0fBoundsException ("Illegal position given.");
70
71
72
73
74
}
75
7660
A 77
@Override
public void clear() {
whlutlllAuto-aenerated method stub
I.
78
79
80
81
82e
A 83
84
85
@Override
public T replace(int givenPosition, T newEntry) {
if((givenPosition >= 1) && (givenPosition <= number0fEntries)) {
Node<T> desiredNode =
T originalEntry = desiredNode.getData();
desiredNode.setData(newEntry);
return originalEntry;
} else {
throw new IndexOut0fBoundsException ("Illegal position given");
getNodeAt (givenPosition);
86
87
88
89
%3D
90
01
Problems
@Javadoc Declaration
Console X
No consoles to display at this time.
![Lijava
44
A
3 import chapter10.ListInterface;
4
Unit13 src
src chapter12 O LList<T>
►
o firstNode: Node<T>
5 public class LList<T> implements ListInterface<T> {
6.
private NodeT firstNode;
private int number0fEntries%;
8
6.
public LList( {
firstNode = null;
number0fEntries = 0;
}
100
11
12
%3D
13
14
private Node<T> getNodeAt (int givenPostion) {
Node<T> currentNode = firstNode;
for (int count =
currentNode = currentNode.getNextNode();
}
return currentNode;
150
16
%3D
17
1; count < givenPostion; count++) {
18
19
20
21
22
23e
A 24
@Override
public void add(T newEntry) {
Node<T> newNode = new Node<>(newEntry);
if(isEmpty())
firstNode = newNode;
else {
Node<T> lastNode =
lastNode.setNextNode (neWNode);
25
26
27
28
29
30
31
32
33
34
35e
A 36
37
38
39
40
41
42
getNodeAt (number0fEntries);
number0fEntries++3;
I
@Override
public void add(int givenPosition, T newEntry) {
if(givenPosition >= 1 && (givenPosition <= number0fEntries + 1)) {
Node<T> newNode = new Node<>(newEntry)%3;
if(givenPosition = 1) {
newNode.setNextNode(firstNode);
firstNode = newNode;
Jelse {
Node<T> nodeBefore = getNodeAt (givenPosition - 1);
Node<T> nodeAfter = nodeBefore.getNextNode();
newNode.setNextNode(nodeAfter);
nodeBefore.setNextNode(newNode) :
%3D
43
44
%3D
45
46
Problems
@ Javadoc Declaration
Console X
No consoles to display at this time.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdad5a646-4583-4c4b-beba-29e57d936914%2F00d51255-5847-46c8-923c-8525e793d9bd%2F6qj2a0q_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Lijava
44
A
3 import chapter10.ListInterface;
4
Unit13 src
src chapter12 O LList<T>
►
o firstNode: Node<T>
5 public class LList<T> implements ListInterface<T> {
6.
private NodeT firstNode;
private int number0fEntries%;
8
6.
public LList( {
firstNode = null;
number0fEntries = 0;
}
100
11
12
%3D
13
14
private Node<T> getNodeAt (int givenPostion) {
Node<T> currentNode = firstNode;
for (int count =
currentNode = currentNode.getNextNode();
}
return currentNode;
150
16
%3D
17
1; count < givenPostion; count++) {
18
19
20
21
22
23e
A 24
@Override
public void add(T newEntry) {
Node<T> newNode = new Node<>(newEntry);
if(isEmpty())
firstNode = newNode;
else {
Node<T> lastNode =
lastNode.setNextNode (neWNode);
25
26
27
28
29
30
31
32
33
34
35e
A 36
37
38
39
40
41
42
getNodeAt (number0fEntries);
number0fEntries++3;
I
@Override
public void add(int givenPosition, T newEntry) {
if(givenPosition >= 1 && (givenPosition <= number0fEntries + 1)) {
Node<T> newNode = new Node<>(newEntry)%3;
if(givenPosition = 1) {
newNode.setNextNode(firstNode);
firstNode = newNode;
Jelse {
Node<T> nodeBefore = getNodeAt (givenPosition - 1);
Node<T> nodeAfter = nodeBefore.getNextNode();
newNode.setNextNode(nodeAfter);
nodeBefore.setNextNode(newNode) :
%3D
43
44
%3D
45
46
Problems
@ Javadoc Declaration
Console X
No consoles to display at this time.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY